W3C home > Mailing lists > Public > public-device-apis@w3.org > March 2010

Re: New draft of FileWriter API posted

From: Eric Uhrhane <ericu@google.com>
Date: Wed, 10 Mar 2010 18:32:35 -0800
Message-ID: <44b058fe1003101832m6cd5df99ie6c1306a43e12db9@mail.gmail.com>
To: Mike Clement <mikec@google.com>
Cc: public-device-apis@w3.org
On Mon, Mar 8, 2010 at 6:30 PM, Mike Clement <mikec@google.com> wrote:
> This is starting to look very useful.  I do have a couple of questions/comments:
>
> 1)  It might be useful for the FileWriter::write method to return the
> number of bytes written so that it more closely matches other common
> file APIs (e.g., fwrite).  Of course that value is often only used for
> detecting the error of "not writing as many bytes as expected", which
> I assume in FileWriter will cause an explicit onerror() invocation.
> It still might be useful for statistics gathering and/or logging,
> though.

You can get this information from the length/position members on
error, and you can keep track of it as it happens via progress events.
 Also, I think it may be less needed with this API, given that it only
writes data of a known size [the Blob].  With APIs that do data type
conversions or expand line endings on write, it might be more
important.

> 2)  I agree with the comment by annevk@opera.com that BlobBuilder
> should have overloaded append() methods.  In fact, I believe that
> BlobBuilder needs more functionality in this regard, especially when
> it comes to getting non-textual data into a Blob.  It looks like
> appendBlob() is meant to address the need of acquiring binary data,
> but it's looking to me that the only way to get binary data into a
> Blob in the first place is by reading it from a file.  One can easily
> imagine a scenario where you have an image element (JPG) and want to
> put its bytes into a Blob and save it out to a file.  It would be
> inefficient to require the data to be encoded into a string just to
> save it out, but I don't see another pathway right now.  Are there
> other Blob acquisition/manipulation techniques out there that I'm
> missing?  I guess what I'm saying is that I might want to capture any
> number of interesting elements as binary data and save them to disk,
> but it's unclear to me whether or not the browser development
> community is embracing the concept of the Blob as a first class
> citizen such that I can expect to access elements as binary where
> those sources are binary to begin with (e.g., images, video, audio).

I've converted the append() methods to overload as Anne recommended.
I've seen discussions of making a way to get a Blob from a Canvas or
an XHR response body; it's a natural extension.

> Looking forward to more File API developments!
>
> --Mike
>
>
>
Received on Thursday, 11 March 2010 02:33:25 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:14:06 GMT