Re: Proposal for an extension XMLHttpRequest to allow sending files

Is the only difference from the Gears proposal the name of the object
("File") and the lack of reading APIs initially?

- a

On Thu, Jul 17, 2008 at 1:14 PM, Sam Weinig <weinig@apple.com> wrote:
> We would like to propose standardizing a way of using XMLHttpRequest to send
> files to the server.  We propose using a similar (and compatible) API to the
> Blob based API proposed by Google Gears
> (http://code.google.com/p/gears/wiki/BlobWebAPIPropsal), but instead of
> sending Blob objects, the File objects would be sent.  This will allow the
> common act of uploading files, now relegated to form submissions with an
> <input type="file">, to have access to ProgressEvents and the ability to
> abort mid way through.
> As with the Blob API, this is reuses the File and FileList interfaces
> exposed by Mozilla
> (see http://developer.mozilla.org/en/docs/nsIDOMFile and http://developer.mozilla.org/en/docs/nsIDOMFileList)
> in a compatible.  We are not proposing a specific way to get the contents of
> the files, but that would be a natural future extension.  Other potential
> future extensions would be access to the icon associated with the file.
>
> Objects implementing the HTMLInputElement interface must also implement the
> FileHTMLInputElement interface.
> interface FileHTMLInputElement {
>    readonly attribute FileList files;
> };
>
> The files attribute must return a FileList containing all the files
> currently selected.  This list is live, and therefore updates if contents of
> the input element change.
> interface FileList {
>    readonly attribute unsigned long length
>    [IndexGetter] File item(in unsigned long index);
> };
>
> Each item in the FileList is File, which is a token representation of file
> on the system.  The fileName attribute returns just the name and not the
> complete path.  The fileSize attribute returns the size of the file in
> bytes.
> interface File {
>    readonly attribute DOMString fileName;
>    readonly attribute unsigned long long fileSize;
> };
>
> Sending a File can be accomplished with an extension to XMLHttpRequest that
> overrides the existing send() method.
> Objects implementing the XMLHttpRequest interface must also implement
> the FileXMLHttpRequest interface.
> interface FileXMLHttpRequest {
>    void send(File data);
> };
>
>
> -Sam Weinig
>

Received on Thursday, 17 July 2008 20:24:24 UTC