directory-upload
directory-upload copied to clipboard
It is unclear how FormData object gets populated when Upload API is used
Upload API is async, but FormData[1] let's one to query items synchronously.
https://xhr.spec.whatwg.org/#interface-formdata
@bakulf
What I'm proposing to fix this issue is to change for FormDataEntryValue in this way: typedef (Blob or Directory or USVString) FormDataEntryValue;
Would be also nice to add:
partial interface FormData { void append(USVString name, Directory value); void set(USVString name, Directory value); }
How does that help with the asynchronousness?
All the querying can happen synchronously if we return Directory object instead its content. Right?
Oh, I see. Yeah, that would work, so FormData object creation. It is just that FormData itself wouldn't actually have a sync way to check what all gets submitted since uploading would actually need to traverse through all subdirectories etc. And that would need to be synchronous. Can we make it async?
That requires big big changes to the FormData object. I prefer to expose the Directory object and keep the 'serialization' of its content just as last step in the HTML Form Submission algorithm.
Well, there is the option to make FormData creation async. Promise<FormData> createFormData(); in HTMLFormElement.