How to download and unzip a zip file on iPad using Phonegap and Zip.js

Posted on 2014-08-16
Last Modified: 2014-08-19
I'm trying to unzip a zip file on ipad that's been downloaded onto the device.  The app itself is build using Phonegap javascript code.  I'm trying to do this using zip.js in combination with FileWriter. The code I have so far is included in the attached file.

Here's the list of console messages that appear on Safari Debug:

Log -  successfully downloaded
Log -  Got the zip file from device storage
Log -  zip reader created
Log -  Got the entries
Log -  Outer: pdf
Log -  Outer: jpg
Log -  js/inflate.js
Log -  Got data from the entries
Log -  Got new file to create
Log -  Inner: jpg
Log -  Write completed.
Log -  Got data from the entries
Log -  Got new file to create  
Log -  Inner: jpg
Log -  Write completed.
Log -  Got data from the entries
Log -  Got new file to create  
Log -  Inner: jpg
Log -  Write completed.

In the above unzipping case, there were in fact 3 files in the zip file and the filenames from entries(i).filename were recorded correctly in Sqlite.  However, there were 2 pdfs and 1 jpeg file in the zip I'm currently trying  to extract, but according to the above console output, it seems there's some synchronicity issue with the way I've written this code since it's trying to extract 3 jpegs it appears.  Also, when I try to view any of the downloaded/unzipped files on the device, the console reports:
TypeError: 'undefined' is not an object (evaluating 'event.url')
TypeError: 'undefined' is not an object (evaluating 'event.type')

So there appears to be an issue with the blob of data from the extracted files that is used in the writer.

Has anyone used zip.js successfully in combination with FileWriter to unzip a file onto an ipad device.  For reference, the zip.js I'm referring to is from here:

I also tried using chromeutils zip functionality which some people have reported having success with to unzip files on devices, but my app is specifically for iPad, so it seems I can't use that.

If you know of any other way to extract the downloaded zip file onto an iPad device, I am also all ears.

Thank you for your assistance.
Question by:sgotte
    1 Comment

    Accepted Solution

    From having spent ages to try to get this to work and having had 0 luck on getting an answer here, StackOverflow and elsewhere, the answer as far as I'm concerned, if anyone needs to know in the future, is that it is impossible.  What I ended up doing, since multiple-file download simultaneously is also impossible with Phonegap as of this date (8-19-2014), is adding another page to the app where they can click to download one file at a time.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Suggested Solutions

         Intro      In this article, I will show you how to parse a JSON in Swift using an open source library called SwiftyJSON ( If you haven't heard of a JSON before, it stands for JavaScript Object Notation…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now