W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2011

[whatwg] File API Streaming Blobs

From: David Flanagan <david@davidflanagan.com>
Date: Fri, 21 Jan 2011 10:55:04 -0800
Message-ID: <4D39D688.7020008@davidflanagan.com>
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";
	x.send();
	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,
>
Received on Friday, 21 January 2011 10:55:04 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:29 UTC