Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

230
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda