JavaScript: XMLHttpRequest () from Firefox addon to get zip
I am trying to create a Firefox addon to request a zip file from a webpage and save it locally / unzip it. I get a 200 response code when I ask for zip as a Blob type, but I'm not sure how to store it as the Firefox file I / O documentation is quite confusing.
getFiles : function (version) {
if(version != "?"){
var xmlhttp=new XMLHttpRequest();
url = "http://github.com/wet-boew/wet-boew/archive/master.zip"
xmlhttp.open("GET", url, true);
xmlhttp.responseType = 'blob';
xmlhttp.onload = function(e) {
if (this.status == 200) {
// Note: .response instead of .responseText
var blob = new Blob([this.response], {type: 'compress/zip'});
}
};
xmlhttp.send();
}
return zip;
},
Any help or advice is greatly appreciated!
source to share
I hardly do it, I just got stuck on how to use the asynchronus zip.js module. You can use nsIZipWriter and nsIZipReader just like the related addon from my comment. But I think async is better, so I am working on this:
https://github.com/Noitidart/AysncZip/blob/master/bootstrap.js
Install the addon, click the icon in the toolbar, download the zip code. Clicking on zipped will save the zip file. Pressing "Decompressed" is currently in progress.
Using XPCOM for zip:
- How to find out nsIZipWriter and nsIZipReader? - for asyn, but on-mainthread doing zips read and write
- https://codereview.stackexchange.com/questions/56821/improvements-to-nsizipreader-and-nsiscriptableinputstream
source to share