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

Re: [File API] Other sources for Blob data.

From: Glenn Maynard <glenn@zewt.org>
Date: Thu, 1 Dec 2011 11:58:49 -0500
Message-ID: <CABirCh_0r2tVRL_tO7sfQY617dkbx5w=N2dZ=_qiwNwey4oL_w@mail.gmail.com>
To: Steve VanDeBogart <vandebo@google.com>
Cc: public-webapps <public-webapps@w3.org>, Tony Payne <tpayne@google.com>
On Tue, Nov 29, 2011 at 4:09 PM, Steve VanDeBogart <vandebo@google.com>wrote:

> In several thought experiments using the File API I've wanted to create a
> Blob for data that I haven't materialized.  It seems that a way to create a
> blob backed by an arbitrary data source would be useful.  In particular, I
> would like to see a blob constructor that takes a URL and size as well as
> one that takes a callback.
>
> A URL constructed blob could use a byte range request when a FileReader
> requests a slice of the blob.  i.e the internal implementation could be
> reasonably efficient.
>

Note that since Blobs need to know their size when constructed,
constructing a blob like this would need to be async.

That would also imply that if you read a whole file this way, you're always
going to make two HTTP requests; a HEAD to determine the size and then a
GET.

A callback backed blob would be a bit more complicated.  Maybe something
> like the interface below, though you'd probably need another level of
> indirection in order to deal with concurrency.
>
> interface BlobDataProvider : EventTarget {
>   void getDataSlice(long long start, long long end);
>   void abort();
>
>   readonly attribute any result;
>    readonly attribute unsigned short readyState;
>
>   attribute [TreatNonCallableAsNull] Function? onloadstart;
>   attribute [TreatNonCallableAsNull] Function? onprogress;
>   attribute [TreatNonCallableAsNull] Function? onload;
>   attribute [TreatNonCallableAsNull] Function? onabort;
>   attribute [TreatNonCallableAsNull] Function? onerror;
>   attribute [TreatNonCallableAsNull] Function? onloadend;
> }
>

FYI:
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-January/029998.html

FWIW, I was thinking along these lines:

interface BlobDataProvider : EventTarget {
  void getSize(BlobDataProviderResult result);
  void getDataSlice(long long start, long long end, BlobDataProviderResult
result);
}

interface BlobDataProviderResult : EventTarget {
  void result(any data);
  void error();
  attribute [TreatNonCallableAsNull] Function? onabort;
}

result can be called multiple times, to provide data incrementally.
Progress events are up to the browser.

That said, the only use case I've seen for it is weak DRM, which isn't very
interesting.

-- 
Glenn Maynard
Received on Thursday, 1 December 2011 16:59:26 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:49 GMT