最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I unzip the zipped file using AngularJs? - Stack Overflow

programmeradmin1浏览0评论

I want to unzip the zipped file while downloading the file using AngularJS.

I am trying with the following code,

For eg:

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

How can I download the actual file My_File.PNG from My_File.PNG.zip in the browser?

I want to unzip the zipped file while downloading the file using AngularJS.

I am trying with the following code,

For eg:

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

How can I download the actual file My_File.PNG from My_File.PNG.zip in the browser?

Share Improve this question asked Apr 7, 2014 at 13:23 GnikGnik 7,45821 gold badges82 silver badges139 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

You can't do it from angular directly, but you can call use the JSUnzip library which you can call from your angular controller https://github./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.

It's a little bit late, but the problem is in the angular request. You have to pass a special parameter, as in
$http.get('...', { responseType: "arraybuffer" }).success(successfunc);
and then proceed with the unzip. Search for this...

发布评论

评论列表(0)

  1. 暂无评论