-
-
Notifications
You must be signed in to change notification settings - Fork 56
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
Content-Length or arbitrary headers #69
Comments
Sorry for the late reply; its been a busy few weeks. I've been thinking about the problems and ideas you're describing most days in my morning shower. A good first step would be to confirm if headers like https://datatracker.ietf.org/doc/html/rfc2046#section-5.1
But then I came across this one: https://datatracker.ietf.org/doc/html/rfc7578#section-4.8
Had they been allowed, we could have looked at using the per file headers and figuring out a way to insert the ones we need using web standard browser APIs for encoding Regardless, that approach would have had the limitation that you wouldn't get metadata about all the files being uploaded up front early in the multipart stream; you would have found out the content length of each file one at a time, at the time each file field is encountered in the stream. Your idea about having a new structure for the |
The point about compatibility is fair. My personal tolerance for backwards compatibility is very low but in this case it's not a big deal to stick the headers in another field. I'll raise a counterpoint that if a client is sending a multipart file upload that the server can't fully understand then failing loudly is better than silently dropping the information contained in the side-channel. Regardless of whether or not you decide in favor of backwards compatibility, I might suggest adding a marker in the top-level Edit: Actually I don't think you'd be able to put it in |
What do you think about adding a new
sizes
map which corresponds to themap
implementation which includes information on the expected size of the uploaded payload. Or, overhaulmap
to contain arbitrary headers for each file. Off the top of my head I'm thinking ofLast-Modified
(advanced caching possibilities)Range
(resumable uploads),Content-Encoding
(compression for large text payloads) would be valuable.Content-Length
in particular in my case is required because I want to stream the request directly from the client right into S3 without needing to buffer the entire thing in memory or disk. S3 requires the length of the payload upfront, so right now I also need to send the payload size along, something likeinput UploadWithSize { file: Upload!, size: Int! }
. It's useful in other cases as well, for example terminating the request early if the size will be too large, allocating an ArrayBuffer to avoid costlymemcpy
s, or filesystem extents. Of course, the stream should error out if the content continues past the givenContent-Length
, or if it closes before.It doesn't seem to be possible to set additional headers via multipart requests over FormData so implementing it in a blessed side-channel would be required. When uploading a single file via fetch or XHR you get the
Content-Length
for free, but once you go through FormData you lose the information.The text was updated successfully, but these errors were encountered: