I am working on a code to perform resumable uploads on google drive via google drive API. I am stuck with the error "Failed to parse Content-Range-Header". Here is a sample code that I have.
const new_access_token = await refreshAccessToken() # Function to fetch new access token every time so as to avoid the error of expiration of access token
const res = await axios.put(resumable_url,{
body: data
},{
headers:{
"Authorization": `Bearer ${new_access_token}`,
"Content-Length": 256000,
"Content-Range": `bytes 0-255999/2000000`
}
})
console.log(res)
I am trying to upload the first 256KB of the file which is basically 2000000 bytes. I have passed a parameter called data which is basically an array of buffer of 256000 bytes. Small chunk of bigger file. It looks something like
<Buffer 0,0,0,32,102,116,121,112,105,15,111,109,0,0,2,0,105,115,111,109,105,115,111,50,97,118,99,49,109,112,52,49,0 ....
Later I will be modify the code to make multiple put requests to add the complete file.
I have successfully fetched a new access_token with refresh_token and resumable_session_uri. But I don't know where I am doing wrong. I have tried to use wildcard as well in Content-Range which we use when we don't know the size of file but unable to resolve the error?