WebAPI/ArchiveAPI: Difference between revisions
< WebAPI
Jump to navigation
Jump to search
m (→See Also: Copy pasta error. This should say Archive API, since it is the Archive API page.) |
|||
Line 70: | Line 70: | ||
== See Also == | == See Also == | ||
Other Web APIs related to the | Other Web APIs related to the Archive API: | ||
* [[WebAPI]] | * [[WebAPI]] |
Revision as of 01:34, 4 October 2012
Archive API Specification
Goals
To provide the ability to read the content of an archive file through DOM File objects.
Status
See bug 772434 for the Archive API implementation.
Proposers
Andrea Marchesini
Features
The Archive API supports the following features:
- Web application developer can get the list of filenames contained in an archive DOM file.
- Web application developer can retrieve the content of files from an archive DOM File.
- The API works asynchronously
Proposed API
interface ArchiveRequest : DOMRequest { [infallible] readonly attribute ArchiveReader reader; // In case of a getFilenames() request, the result is an array of DOMString // If this is a getFile() request, the result is a DOM File } [Constructor(Blob blob)] interface ArchiveReader { ArchiveRequest getFilenames(); ArchiveRequest getFile(DOMString filename); };
Examples
- How to get the list of files contained in an archive?
var blob = ...; var reader = ArchiveReader(blob); var h = reader.getFilenames(); h.onerror = function() { ... } h.onsuccess = function() { for (var i = 0; i < this.result.length; ++i) { something(this.result[i]); // this.result[i] is a DOMString } }
- How to get a DOM File from the archive?
// how to get a specific file: var hf = reader.getFile('image.png'); hf.onerror = function() { ... } hf.onsuccess = function() { // this.result is a DOM File alert('Filename: ' + this.result.name + '\n' + 'ContentType: ' + this.result.type + '\n' + 'Size: ' + this.result.size); }
See Also
Other Web APIs related to the Archive API: