Fetch API uploads corrupted Excel files to Dropbox
I'm using a Dropbox SDK JS ("dropbox": "^10.10.0"
) to upload files via filesGetTemporaryUploadLink
, this method returns a temporal URL for file uploading.
The way I upload a file:
const fileUploadResult = await fetch(uploadDestination.url, {
body: fileData,
cache: "no-cache",
credentials: "same-origin",
headers: {
"Content-Type": "application/octet-stream"
},
method: "POST",
mode: "cors"
});
When I upload PDFs, everything is working OK, but when I try to upload .xlsx
file, this file is uploaded in a corrupted way.
I've tried to play with Content-Type
, but when I change application/octet-stream
to Excel's MIME (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
) or to binar/octet-stream
, I get the error:
Failed to load resource: the server responded with a status of 400 (Bad Request)
That's quite strange, what's the difference between sending PDFs and Excel files via POST
with Fetch API?
from Recent Questions - Stack Overflow https://ift.tt/2ZDgk2j
https://ift.tt/eA8V8J
Comments
Post a Comment