如何使用AngularJs解压缩压缩文件?

时间:2014-04-07 13:23:06

标签: javascript html html5 angularjs angularjs-directive

我想在使用AngularJS下载文件时解压缩压缩文件。

我正在尝试使用以下代码,

例如:

<a download="My_File.PNG" target="_self" ng-href="Path of the zip file/My_File.PNG.zip">My_File.PNG</a>

如何从浏览器中的My_File.PNG下载实际文件My_File.PNG.zip

2 个答案:

答案 0 :(得分:2)

你不能直接从角度来做,但你可以调用使用JSUnzip库,你可以从角度控制器调用https://github.com/augustl/js-unzip

     var myZip = ... // Get it with an XHR request, HTML5 files, etc.
     var unzipper = new JSUnzip(myZip);
     unzipper.isZipFile();      // true or false

     unzipper.readEntries();    // Creates "entries"
     unzipper.entries;          // Array of JSUnzip.ZipEntry objects.

答案 1 :(得分:0)

这有点晚了,但问题在于角度请求。您必须传递一个特殊参数,如中 $ http.get('...',{responseType:“arraybuffer”})。success(successfunc);
然后继续解压缩。搜索这个...