JavaScript:来自 Firefox 插件的 XMLHttpRequest() 以获取 zip

JavaScript: XMLHttpRequest() from Firefox addon to get zip

我正在尝试构建一个 Firefox 插件以从网页请求一个 zip 文件并存储它 locally/decompress。当我请求 zip 作为 Blob 类型时,我收到了一个 200 响应代码,但我不确定如何存储它,因为 Firefox 文件 I/O 文档非常混乱。

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

File I/O documentation

如有任何帮助或建议,我们将不胜感激!

我几乎不知道,我只是想弄清楚如何使用异步 zip.js 模块。您可以使用 nsIZipWriter 和 nsIZipReader,就像我评论中的链接插件一样。但我认为异步更好,所以我正在努力:

https://github.com/Noitidart/AysncZip/blob/master/bootstrap.js

安装插件,点击工具栏图标,下载zip。单击压缩会将其保存为压缩文件。单击 "Decompressed" 目前正在进行中。

使用 XPCOM 压缩: