Re: Proposal for sending multiple files via XMLHttpRequest.send()

Thank you for all your great feedbacks.
Yes, the first approach is simpler and it requites far less work from the
author and thus less error prone. However, I think the second approach does
provide more flexibilities that might fit for the different data assembling
and sending purpose. The author can use it to upload multiple attached
files, save a set of client generated items, or even send any combinations
of string data and file data.

For example, the presentation web application wants to save a set of client
generated slides to the server. Some of slides include attached files, like
a video clip. It will be much easier for the author to send all the data to
the server via the second approach:

    var payload = new Array;
    payload.push(header_for_slide1);
    payload.push(data_for_slide1);
    payload.push(header_for_slide2);
    payload.push(data_for_slide2);
    payload.push(attached_file1_for_slide2);
    payload.push(attached_file2_for_slide2);
    ...
    xhr.send(payload);

Since XMLHttpRequest spec has already added the overload for send(document),
why not just adding more overload for file and array of items? IMHO, having
similar send*** methods, like sendFile, together with overloads of send()
might make the API more complicated.


2009/9/11 Yaar Schnitman <yaar@chromium.org>

>
>> How is supposed the web application to detect that the browser
>> supports this feature?
>>
>>
> Maybe instead of overloaded send, we should create new method
> sendFile(File) and sendFiles(File[]).
>
> And between the two approaches, the first one is simpler, but the
>> second one allows to send the files one each time and add other form
>> data in the request.
>>
>> Maybe sendFiles(File[], [Strings[]])?
>
>

Received on Saturday, 12 September 2009 06:46:52 UTC