-
Notifications
You must be signed in to change notification settings - Fork 341
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
[Suggestion] Add more per-file (custom) header to multipart #1130
Comments
This seems somewhat reasonable once there is a much more solid definition of multipart/form-data and interoperable implementations of that (see existing issues against whatwg/html). |
if Imo i think that the boundary was a bad style decision. smarter containers like zip, tar and other multi file container specifies the byte length before every entry or at the end in some central dictionary so you can jump/scan a hole blob without having to scan for a boundary separator. So i think that a content-length header would be an enhancement to the old multipart/form-data specification. |
For the record, I'm working on defining multipart/form-data in https://github.com/andreubotella/multipart-form-data, including a parser for use in |
Some demonstration code
What's generated:
I think some more per-file headers could enhance the server validation
for instance. it would be useful to know before you receive the hole file how large a per file size is, not the hole formdata
content-length
. So you can abort upload request prematurely if one is sending a too large file. While we are at it, why can't we as well throw in the less usefulLast-Modified
header as well? that is also known on the client side before it's being uploaded viafile.lastModified
.This things could easily be added if you pass in a File without changing any code. But another idea could also be to allow sending custom headers as well when using the
FormData
apiThis could allow for a way to batch a bunch of requests into one request also. if you get a bit creative
I have seen some developer use a custom multipart library to batch multiple request/responses into one
As opposite to this a way to read individual per-entries headers could also be useful so you can decode it also.
I have no idea how it would fit into the existing getter function (
fd.get(x)
) but withfd.entries()
you have the option to append stuff (?) but then it would no longer be a tuple and could technically break some code that expect to use tuples (like theObject.fromEntires()
The text was updated successfully, but these errors were encountered: