[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1024
  • Last Modified:

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

Hello,
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: http://gildas-lormeau.github.io/zip.js/

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.
0
sgotte
Asked:
sgotte
1 Solution
 
sgotteAuthor Commented:
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.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now