-
-
Notifications
You must be signed in to change notification settings - Fork 936
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
Support multipart/form-data encoding #1810
Comments
Got v12 supports async iterators so https://www.npmjs.com/package/formdata-node should work out of the box. |
https://github.com/jimmywarting/FormData is a no as of now - Got doesn't support Blobs |
Builtin encoding will be removed from formdata-node in next major release, because it must be handled by HTTP client. This suggestion is not about support for some specific package, but rather for |
Please consider removing |
Yeah, I will do something about this. |
Decided to just use crypto.randomBytes for boundary string, should be more than enough. Kind of don't want to use just Math.random() for this, but it would've be fine too. Available in form-data-encoder 1.1.0, now it weights 35.8 KB. I will reduce the size once again when I drop CJS support. |
This comment has been minimized.
This comment has been minimized.
It seem to be fine as well, found few other implementations which are using Math.random() for boundaries (one of them is part of Deno). form-data-encoder integration seem to work fine, the tests are passing and I can file a PR for further discussion if you want. |
|
Firefox only use numbers for it's boundary. They don't have to be super random. Math.random is fine and more cross Deno/Browser/nodejs friendlier as it dose not depend on any core nodejs stuff |
Yes, I already switched to Math.random() |
Is it possible to use the got with multipart/formdata? |
Yes. It took me quite a while to find how to upload a file using formdata, so leaving the link here in hope it helps others in the future: #1877 (reply in thread) |
Starting with Got v12, |
What problem are you trying to solve?
General support for spec-compatible FormData implementations.
Describe the feature
Current form-data encoding in Got relies on
form-data
package implementation which is not spec-compatible and lacks of most of FormData interface methods. I suggest to add general support for this type of request body. How this can be done:formdata-node
, orformdata-polyfill
, or any other implementation as long as it follows the spec;form-data-encoder
package instead;References:
If you don't mind to use
form-data-encoder
to handle this encoding, I can file a PR to bring its support.Checklist
The text was updated successfully, but these errors were encountered: