Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
Issue getting google workspace file (JavaScript)

Im calling request from google workspace file with gapi using this code

gapi.client.drive.files.export({
  fileId: fileId,
  mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
})

from that code i get response back of base64 string to convert as a blob but when i open file in google docs or msword file is corrupt and not working but if i change mimeType into application/pdf it working

same thing also happen in if i request file with application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

am i doing something wrong here or i there is other way to getting file workspace

md5Checksum is not available

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Finally i found solution for this issue according to this official documentation we have two type we can download from google drive.

here my code how i request for file

const res = await drive
            .files
            .export({
                    fileId: fileId,
                     mimeType: yourMimeTarget
                    })
                    .then(res => res)
const blob_file = fetch(`data:${yourMimeTarget};base64,${btoa(res.body)}`)
                 .then(res => res.blob())

so after you fetch google workspace file you will get base64 string than you can convert it into blob

about 4 years ago · Juan Pablo Isaza Report

0

As mentioned in the official documentation for files.get:

Response

By default, this responds with a Files resource in the response body. If you provide the URL parameter alt=media, then the response includes the file contents in the response body. Downloading content with alt=media only works if the file is stored in Drive. To download Google Docs, Sheets, and Slides use files.export instead. For further information on downloading files, refer to Download files.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!