How can I unzip the compressed file using AngularJs?

advertisements

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?


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.