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

235
Views
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
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!