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;
},

      

I / O file documentation

Any help or advice is greatly appreciated!

+3


source to share


1 answer


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:

+1


source







All Articles