- From: Darin Fisher <darin@chromium.org>
- Date: Tue, 20 Oct 2009 01:56:47 -0700
- To: Anne van Kesteren <annevk@opera.com>
- Cc: public-webapps@w3.org
- Message-ID: <bd8f24d20910200156g6e4857a0race1e6353a358f05@mail.gmail.com>
On Tue, Oct 20, 2009 at 1:37 AM, Anne van Kesteren <annevk@opera.com> wrote: > On Tue, 20 Oct 2009 08:55:21 +0200, Darin Fisher <darin@chromium.org> > wrote: > >> I'd like to revive the "Proposal for sending multiple files via >> XMLHttpRequest.send()" thread >> started by Jian Li back in September. >> >> As pointed out on that thread, sending a JS array of strings and File >> references isn't going >> to fly due to an array of strings already having meaning. >> >> That thread concluded with Jonas Sicking saying: >> >> I definitely think that we need to add some way of sending a stream >>> that is a concatenation of strings, binary data, and files, without >>> requiring the files to be read. >>> >> >> What should this look like? Should there be a new global constructor for >> an >> object that supports methods like appendText and appendFile? Like this: >> >> var data = new UploadData; >> data.appendText("foo"); >> data.appendFile(fileRef); >> xhr.send(data); >> >> I like the idea of creating a primitive that does not enforce any >> encoding. >> >> Thoughts? >> > > I think for a lot of authors the easiest would be easiest if it was in the > form of multipart/form-data as then they do not have to do anything special > to get the data on the server. > > That does address the primary use case, but do you really think that we should rule out the use case of custom encodings? (At least for Gecko and WebKit, it is really trivial to support the more free-form interface since the underlying network layers speak in terms of a list of strings and file references.) If we do go the more specific route, then it could look like this: var data = new FormData; data.appendText("name1", "value"); data.appendFile("name2", fileData); xhr.send(data); The UA could populate the filename attribute of the Content-Disposition header based on the given fileRef. Same goes for the Content-Type header. Hmm... this may indeed be a good way to go since I don't think the proposed FileData ( http://dev.w3.org/2006/webapi/FileUpload/publish/FileAPI.html#FileData-if) interface includes a name attribute. -Darin > > -- > Anne van Kesteren > http://annevankesteren.nl/ >
Received on Tuesday, 20 October 2009 08:57:21 UTC