-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
missing boundary in Content-Type for multipart posts #746
Comments
A similar discussion ongoing for POSTman here: postmanlabs/postman-app-support#576 |
As a workaround, I got this to work, with the proper
|
@bdefore can you explain how you got it to work? In your example you're not setting the proper Content-Type which you said was needed for it to work correctly. |
@pharno still using that workaround |
@bdefore +1. Same problem here. |
+1 Same problem |
Also workaround potential superagent issue at ladjs/superagent#746
+1 on this issue. I can't use |
I found that uploading files without specifying the |
@meenalt Why can't you use
|
You should probably use |
The same problem. |
I think the solution is to never set content-type manually for multipart. |
@pornel thank you! Could you please explain in details what is the correct way to upload file with using 'superagent' and without manual setting of 'content-type'? |
superagent.post(url)
.attach('field_name', file_object) // file_object can be File or Blob
.then(result => {}) // .end() works too |
@pornel Wow!! Thank YOU! I was totally dumbstruck for a few hours. |
Thank you so much @pornel You saved my day!! |
Thank you so much @pornel, wow !! |
req.set('enctype', 'multipart/form-data') |
@ymma Thank you so much. Once I've added req.set('enctype', 'multipart/form-data') to my request, it started to define correct boundaries of the file. |
@ymma that worked perfectly. I am not very savvy with headers and stuff, would you mind explaining why this works like this? Best, |
I tried setting content type to undefined and it works .set('Content-Type', undefined) |
I'm attempting to use superagent to upload files to Cloudinary. I have the following code:
Running on localhost, I'm getting the error from their API:
But I believe this is a red herring, since I'm able to upload successfully with the Dropzone library, loaded from a local dropzone.js file. It also gives an error response if I comment out the file attachments - it correctly tells me that a parameter is missing.
This led me to look into the request in Chrome Inspector:
Request Headers:
Request Payload:
Note the
Content-Type
field, which is lacking the boundary. That's the only difference I can see from the corresponding dropzone.js request and the superagent one:Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryzg196Oz74o5Y3jvp
I cannot set the
Content-Type
manually with the boundary because it is generated by superagent.Any ideas?
The text was updated successfully, but these errors were encountered: