W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2009

[whatwg] An BinaryArchive API for HTML5?

From: Gregg Tavares <gman@google.com>
Date: Wed, 29 Jul 2009 23:49:12 -0700
Message-ID: <de4bd3190907292349x1df7dfc9occb780ae7190496b@mail.gmail.com>
If this has already been covered just point me in that direction.

Assuming it hasn't...

What are people's feelings on adding a Binary Archive API to HTML5?

I'm sure for many that sets off alarms so let me try to describe what I mean
and a case for it.

It seems like it would be useful if there was browser API that let you
download something like gzipped tar files.

The API would look something like

var request = createArchiveRequest();
request.open("GET", "http://someplace.com/somearchive.tgz");
request.onfileavailable = doSomethingWithEachFileAsItArrives;
request.send();

function doSomethingWithEachFileAsItArrives(binaryBlob) {
  // Load every image in archive
  if (binaryBlob.url.substr(-3) == ".jpg") {
     var image = new Image();
     image.src = binaryBlob.toDataURL();  // or something;
     ...
  }
  // Look for a specific text file
  else if (binaryBlog.url === "myspecial.txt") {
    // getText only works if binaryBlob is valid utf-8 text.
    var text = binaryBlob.getText();
    document.getElementById("content").innerHTML = text;
  }
}

Hopefully from the example above you can see that a .tgz file is downloaded
and as each file becomes available it is handed to the JavaScript as binary
blobs through an onfileavailable callback. A blob can be passed to an img,
video, audio, assuming its in the correct format. It can also be gotten as a
string assuming it is valid utf-8

Why is this needed?  Because with canvas tag and the upcoming 3dweb (canvas
3d) it will be common for an application to need to download thousands of
small files. A typical canvas 3d application will need all kinds of small
pieces of geometry data as well as hundreds of textures and sound files to
make even a modest game.

As it is now, each tag is apparently required to implement it's own network
stack for getting data. Image does things its way (progressively loading),
Video and Audio both support steaming. That's all great. But it seems like
as more and more types get added some support for a more centrally
implemented system would go a long way to helping some of these new APIs.

Thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20090729/98735fb6/attachment-0001.htm>
Received on Wednesday, 29 July 2009 23:49:12 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:51 UTC