Gnik
Gnik

Reputation: 7436

How can I unzip the zipped file using AngularJs?

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?

Upvotes: 3

Views: 7886

Answers (2)

Andrea
Andrea

Reputation: 565

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...

Upvotes: 0

reach4thelasers
reach4thelasers

Reputation: 26909

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.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.

Upvotes: 2

Related Questions