resume uri:https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable&upload_id=ADPycducJGWQ62n6E0K5mD81RGJw-0eIsga8dBxarfSY_2Pk5hFJhBs230Q8ay
PUT请求:
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)
代码有问题吗
过了一会儿,我得到这个:
- 错误。
客户端发出请求的时间过长。
我们只知道这些。
@kevintechie感谢您的回复。这里的问题是axios
放请求。下面的代码
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))