我正在使用 Dropbox SDK JS ( "dropbox": "^10.10.0"
) 通过 上传文件filesGetTemporaryUploadLink
,此方法返回用于文件上传的临时 URL。
我上传文件的方式:
const fileUploadResult = await fetch(uploadDestination.url, {
body: fileData,
cache: "no-cache",
credentials: "same-origin",
headers: {
"Content-Type": "application/octet-stream"
},
method: "POST",
mode: "cors"
});
当我上传 PDF 时,一切正常,但是当我尝试上传.xlsx
文件时,该文件以损坏的方式上传。
我试过玩Content-Type
,但是当我更改application/octet-stream
为 Excel 的 MIME ( application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
) 或 时binar/octet-stream
,我收到错误:
加载资源失败:服务器响应状态为 400(错误请求)
POST
这很奇怪,通过Fetch API发送 PDF 和 Excel 文件有什么区别?