[whatwg] An BinaryArchive API for HTML5?

Gregg Tavares gman at google.com
Wed Jul 29 23:49:12 PDT 2009


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-0002.htm>


More information about the whatwg mailing list