Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Very confusing (and wrong) file upload option #45

Open
sciabarracom opened this issue Jan 3, 2021 · 2 comments
Open

Very confusing (and wrong) file upload option #45

sciabarracom opened this issue Jan 3, 2021 · 2 comments

Comments

@sciabarracom
Copy link

sciabarracom commented Jan 3, 2021

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.

@rabbah
Copy link
Contributor

rabbah commented Jan 3, 2021

If that works for OCR too, we can simplify the code.

@sciabarracom
Copy link
Author

It should the problem is file upload is deep buried inside a react-file-uploader that is also deprecated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants