title: Unzipping file in phonegap using zip.js
body: <p>am using PhoneGap Cordova 3.3.0 and latest version of <a href="http://gildas-lormeau.github.io/zip.js/core-api.html" rel="nofollow">zip.js</a>. The script is able to get the list of files inside the archive but is unable to get any binary data. Am using the fix by <a href="https://github.com/gildas-lormeau/zip.js/pull/70" rel="nofollow">Hugeen</a> but no luck.</p>
  
  <pre class="lang-js prettyprint-override"><code>function decompress(fullsavepath, filename){
      zip.useWebWorkers = false;
      file_system.root.getFile("app_cache/temp.zip", {}, function(fileEntry){
          fileEntry.file(function (file) {
  
              zip.createReader(new zip.BlobReader(file), function(reader) {
  
                  // get all entries from the zip
                  reader.getEntries(function(entries) {
                      if (entries.length) {
                          //Output zip file contents
                          for(var i=0; i&lt;entries.length;i++){
                              console.log(entries[i].filename);
                          }
  
                          //Try to decompress file no. 3
                          console.log('---- entries[2] '+entries[2].filename);
                          entries[2].getData(new zip.BlobWriter(), function(unzipData){
                              console.log(unzipData);
                          },null, null);
                      }
                  });
              }, null);
  
          })
  
      },null);
  }
  </code></pre>
  
  <p>Here is my console log with the relevant messages:</p>
  
  <pre><code>Console: ----entries[2] photoalbum/bpage1.jpg at file:///android_asset/www/dl/index.html:315
  Console: processMessage failed: Message: S01 File821048650 AUEsDBBQAAAAIAEFVCEMFqmCrQAsHAMa3BwASAAAA at file:///android_asset/www/cordova.js:1034
  Console: processMessage failed: Error: TypeError: undefined is not a function at file:///android_asset/www/cordova.js:1035
  Console: processMessage failed: Stack: TypeError: undefined is not a function
  Console:     at inflate (file:///android_asset/www/dl/js/vendor/zip/zip.js:429:18)
  Console:     at file:///android_asset/www/dl/js/vendor/zip/zip.js:600:16
  Console:     at BlobWriter.init (file:///android_asset/www/dl/js/vendor/zip/zip.js:297:4)
  Console:     at file:///android_asset/www/dl/js/vendor/zip/zip.js:596:12
  Console:     at [object Object].&lt;anonymous&gt; (file:///android_asset/www/dl/js/vendor/zip/zip.js:203:5)
  Console:     at file:///android_asset/www/plugins/org.apache.cordova.core.file/www/FileReader.js:352:20
  Console:     at Object.callbackFromNative (file:///android_asset/www/cordova.js:292:54)
  Console:     at processMessage (file:///android_asset/www/cordova.js:1029:21)
  Console:     at Function.processMessages (file:///android_asset/www/cordova.js:1063:13)
  Console:     at pollOnce (file:///android_asset/www/cordova.js:933:17) at file:///android_asset/www/cordova.js:1036
  </code></pre>
  
  <p>------ <strong>UPDATE 2014-04-07</strong> -------------</p>
  
  <p>In the end we used an alternative approach to solve the problem. Google developed a native plugin for Android and iOS - <a href="https://github.com/MobileChromeApps/zip" rel="nofollow">https://github.com/MobileChromeApps/zip</a></p>
  
  <p>It is quite straight forward, and honestly one of the rare plugins we used that succeeded doing what we needed on first try.</p>
  
  <p>Example:</p>
  
  <pre><code> zip.unzip("cdvfile://localstorage/downloaded.zip", 
             "cdvfile://localstorage/my_data/path/", 
             function(){
                console.log('Zip decompressed successfully');
             }
   );
  </code></pre>
  
  <p>PS: Cordova has since been updated to 3.4.0 - My original question used paths like <code>file:///android_asset/www</code> which has all been replaced with the new <code>cdvfile://</code></p>