[whatwg] File API Streaming Blobs

David Flanagan david at davidflanagan.com
Fri Jan 21 10:55:04 PST 2011

Doesn't the current XHR2 spec address this use case?
Browsers don't seem to implement it yet, but shouldn't something like 
this work for the original poster?

	x = new XMLHttpRequest()
	x.open("GET", "http://my-media-file");
	x.responseType = "blob";
	var nbytes = 0;
	x.onprogress = function(e) {
	   var blob = x.response.slice(nbytes, e.loaded-nbytes);
            nbytes += blob.size;
	   var reader = new FileReader();
            reader.readAsArrayBuffer(blob, function() {
                // process blob content here


     David Flanagan

On 01/21/2011 02:02 AM, Jeremy Orlow wrote:
> Would something like this tie in to the<device>  work that's being done
> maybe?
> ---------- Forwarded message ----------
> From: Adam Malcontenti-Wilson<adman.com at gmail.com>
> Date: Fri, Jan 21, 2011 at 6:21 AM
> Subject: [chromium-html5] File API Streaming Blobs
> To: Chromium HTML5<chromium-html5 at chromium.org>
> Hi.
> I'm trying to make an application which will download media files from
> a server and cache them locally, as well as playing them back but I'm
> trying to figure out how I could do so without making the user wait
> for the entire file to be downloaded, converted to a blob, then
> saved.
> For example, suppose that I create a new BlobBuilder, append "hello",
> get the Blob, and then create an object url from that blob, and then
> open the object url. Any other text that I append to the BlobBuilder
> would not go into the old blob that I created a url for, and hence not
> shown making "streaming" impossible.
> Is there any other methods in the spec(s) to implement such
> streaming?
> If not, perhaps there needs to be yet another object to have a way of
> creating a "StreamingBlob" that doesn't "close" the virtual connection
> to the browser until a close method is called, thereby facilitating
> streaming.
> Thanks,

More information about the whatwg mailing list