简体   繁体   中英

With resumable uri i got by google drive api post request, there is no response while uploading with that uri

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.

@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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM