MobileChromeApps / cordova-plugin-zip

Zip plugin for Cordova apps
Other
168 stars 207 forks source link

IOS UNZIP FAIL #15

Closed benjaminhorner closed 10 years ago

benjaminhorner commented 10 years ago

Hi guys,

Thanks for sharing this great work, and especially thanks for the hard work. I've successfully downloaded and installed your plugin for a Cordova project on iOS. However, I get the following error every time I try and unzip a file : Error occurred during unzipping - failed to open zip file (sadly, that is the only error output I get, so it is little to go on)

I have double checked the paths (absolute paths to system Documents directory where I download files using FileTransfer), the zip file (successfully unzipped on my machine), the size and type of the zipped file (txt, json, sqlite…) but I keep getting the error. Tested on iOS 7.0.6 on an iPhone 4S and iPhone simulators (all).

Could this be a bug or am I doing something wrong ?

bshepherdson commented 10 years ago

Are you using the latest Cordova File plugin? It has changed the paths it returns from filenames to proper URLs. There was a fix last week for Android, but the analogous change probably needs to be made for iOS as well.

I'll check with the local guy who made the File plugin changes; it should be a simple fix to make the iOS code resolve the URL that came from Javascript into a filename that can be opened.

benjaminhorner commented 10 years ago

Hi,

Thanks for the (very) quick response. I AM indeed using the latest Cordova File plugin and the latest Cordova build to (3.3.0). So I access the root path via this line 'fileSystem.root.toURL()' (the toURL() is the part that has changed from previous versions).

I'll also have a look into it see if I can find a way round. I hadn't thought about the URL change in the fileTransfer plugin. I'll let you know if I come up with anything.

clelland commented 10 years ago

Hi Benjamin,

The lastest push should fix this -- there's now an explicit dependency on the File plugin (but you're using that anyway, so you shouldn't notice anything different). Both the source zip file and the destination directory arguments will now accept cdvfile:// URLs.

Re-open this issue if you're still having problems with this.

benjaminhorner commented 10 years ago

Hi Ian,

Thanks for taking the time to look into it.

I downloaded the latest fix but sadly I am still getting an error. Maybe I'm doing something wrong ? Here are my logs. Hope it helps :

PS : I don't have commit access so I can't re-open the issue.

clelland commented 10 years ago

Sorry, @benjaminhorner, I probably pushed that code a day or two too soon. It actually depends on the dev version of the File plugin. That's on schedule to be released tomorrow as v1.0.1.

If you can wait for tomorrow's release, then you'll be able to upgrade File; otherwise, you can check out the dev branch of apache/cordova-plugin-file and use that.

benjaminhorner commented 10 years ago

Hi again,

After a bit of debugging (not much though as I am no Obj C wizard), it appears the error occurs along these lines : NSLog(@"File Plugin found !=nil"); NSLog(@"Value of URLString = %@", urlString); CDVFilesystemURL* url = [CDVFilesystemURL fileSystemURLWithString:urlString]; path = [filePlugin filesystemPathForURL:url]; NSLog(@"Value of PATH = %@", path);

To be precise, the EXACT line causing the error is this one : CDVFilesystemURL* url = [CDVFilesystemURL fileSystemURLWithString:urlString];

The file path I pass as an argument in my JS is 'cdvfile://localhost/persistent/planogaz.json.zip'. The output of NSLog urlString is 'cdvfile://localhost/persistent/planogaz.json.zip' (correct path)

I thought it could be a path issue so I NSLogged the paths in the File Transfer plugin (which is working fine on this project) and they are identical to that of the Zip plugin.

I'm at a loss as to where the error is… Still searching !

benjaminhorner commented 10 years ago

Hi Ian,

Thanks for your answer. I just downloaded the dev branch from the File Plugin Git repo and the UNZIP works like a charm. Thanks a million !

I guess the issue is now closed :-)