0

resumable uri: https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&upload_id=ADPycducJGWQ62n6E0K5mD81RGJw-0eIsga8dBxarfSY_2Pk5hFJhBs230Q8ay

PUT request:

let postFile =  await axios.request(
  {
    method: "PUT",
    url: resumableURI,
    headers: {
      Authorization: `Bearer ${process.env.GOOGLE_ACCESS_TOKEN}`,
      "Content-Length": req.files.muploadedFile.size,
    },
    body : bufferToStream(buffer)
  }
)
console.log(postFile.data)

Is there any problem with code

After a while im getting this:

  1. That’s an error.
    Your client has taken too long to issue its request.
    That’s all we know.
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
karthi keyan
  • 1
  • 1
  • 4

1 Answers1

0

@kevintechie Thank you for response. Problem here is with axios put request. The code below works

axios.put(
  `${resumableURI}`,
  {
    bufferToStream(buffer)
  },{
    headers: {
      Authorization: `Bearer ${process.env.GOOGLE_ACCESS_TOKEN}`,
      "Content-Length": req.files.muploadedFile.size,
      "Content-Range": `bytes 0-${req.files.muploadedFile.size-1 }/${req.files.muploadedFile.size}`
    }
  }
).then( resp => {
  console.log(resp)
}).catch( e => console.log(e))
Tyler2P
  • 2,324
  • 26
  • 22
  • 31
karthi keyan
  • 1
  • 1
  • 4