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

226
Visualizações
How to upload file in Drive using drive API which is fetched from some other system in node.js

I am pulling a file from a 3rd party system and it is returning the data in the response as a string. Now when using that string to upload to drive it is uploading but the file is not opening. I tried converting the string to Blob but it is not possible in node.js. How can I upload correctly using that string of data?

let res=await axios.get("getting the file from 3rd party system",headers);
  
  let fileToUpload=res.data;   // storing the file in variable

  
 let data={
  name:'image.png',
  parents:['1BD50Xdf5456ghec8Ccwa5YNEkpgPaOxdE_M']
};
let head={
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'Content-Length':127494,
        'Authorization': 'Bearer '+driveaccessToken
    }
};
  //request to upload metadata
 res=await axios.post('https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable',JSON.stringify(data),head);

  //getting the content upload url from response
 let uploadUrl=res.headers.location;
 
 //uploading the content
  res = await axios.put(uploadUrl,fileToUpload,head);
  console.log(res.status);

about 4 years ago · Juan Pablo Isaza
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