demo-projects
demo-projects copied to clipboard
Very confusing (and wrong) file upload option
In credential.js
in the ocr example the options for generating a file upload for put are:
const options = {
headers: {
'Content-Type': 'multipart/formdata; charset=UTF-8', // wrong!
'Access-Control-Allow-Origin': '*',
'Cross-Domain': true
}
};
Actually when you do a PUT you DO NOT HAVE to use multipart form/data, just upload the file as is. As a result, you have to do ad upload generating a put request that will upload the file as a binary string also specifying Contet-Type "multipart/formdata".... that is not.
I went crazy following the example because I tried to upload with put and multiplart/form-data that is NOT decoded by the put.
I was finally able to perform the upload removing the Content-Type when generating the file upload and then doing a plain put of the file to upload.