If this has already been covered just point me in that direction.<br><br>Assuming it hasn't...<br><br>What are people's feelings on adding a Binary Archive API to HTML5?<br><br>I'm sure for many that sets off alarms so let me try to describe what I mean and a case for it.<br>
<br>It seems like it would be useful if there was browser API that let you download something like gzipped tar files.<br><br>The API would look something like<br><br>var request = createArchiveRequest();<br>request.open("GET", "<a href="http://someplace.com/somearchive.tgz">http://someplace.com/somearchive.tgz</a>");<br>
request.onfileavailable = doSomethingWithEachFileAsItArrives;<br>request.send();<br><br>function doSomethingWithEachFileAsItArrives(binaryBlob) {<br> // Load every image in archive<br> if (binaryBlob.url.substr(-3) == ".jpg") { <br>
var image = new Image();<br> image.src = binaryBlob.toDataURL(); // or something;<br> ...<br> }<br> // Look for a specific text file<br> else if (binaryBlog.url === "myspecial.txt") {<br> // getText only works if binaryBlob is valid utf-8 text.<br>
var text = binaryBlob.getText();<br> document.getElementById("content").innerHTML = text;<br> } <br>}<br><br>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<br>
<br>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. <br>
<br>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.<br>
<br>Thoughts?<br><br><br>