W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2009

Re: The most basic File API use case

From: Peter O. Ussuri <ussuri@threetags.com>
Date: Mon, 23 Nov 2009 09:34:38 -0500
Message-ID: <65dfc9010911230634u1a267164w66171bc51c2e1fc1@mail.gmail.com>
To: arun@mozilla.com
Cc: public-webapps@w3.org
> The current File API draft lets a web app to read the file, but there seems
>> to be no easy way for a web app to construct an arbitrary binary file and
>> trigger a SaveAs/download dialog, with the file name suggested by the app.
> I agree with this use case being a logical next step.
> As far as Group 0 goes, I agree and think we'll need:
> 1. A script initiated SaveAs mechanism.
> 2. Something like BlobBuilder (as you point out).
> Next steps can evolve from these.
May I suggest then a specific implementation, in order to move the process
forward a bit. All names/signatures/behaviors below are intended to start
the discussion only, and not as a draft or anything formal. :)

Based on [1] <http://www.w3.org/TR/2009/WD-FileAPI-20091117/> and
we can have two interfaces introduced into the File API specification:

BlobBuilder: based on Google Gears

interface BlobBuilder {
    void appendText( in DOMString text, [Optional] in DOMString encoding );
    void appendBinaryString( in DOMString text ); /* same as in FileReader
    void appendByte( in long val ); /* if val is not in the [0-255] range,
throws an exception */
    void appendBlob( in Blob blob );

    /* this method can probably be asynchronous, but IMHO this is not
necessary at the "Group 0 use case" stage */
    Blob getBlob();


interface FileWriter {
    /* shows the SaveAs dialog, returns the saved File or null if
error/canceled by the user */
    /* can be made synchronous (modal) or asynchronous, I'm not sure at the
moment which approach is better  */
    File saveBlobAsFilePrompt( in Blob blob, in [Optional] DOMString
suggestedFileName ); /* synchronous/modal variant; asynchronous will return
nothing and have events */

Later FileWriter can be expanded to cover other use cases.


[1] http://www.w3.org/TR/2009/WD-FileAPI-20091117/
[2] http://code.google.com/apis/gears/api_blobbuilder.html
Received on Monday, 23 November 2009 14:35:12 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:21 UTC