Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

222
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda