phonegap / phonegap-plugin-contentsync

Download and cache remotely hosted content
Apache License 2.0
206 stars 98 forks source link

Download OK, Unzip OK, but unreadable asset #110

Closed mparpaillon closed 8 years ago

mparpaillon commented 8 years ago

Hi, I'm using this plugin on iOS9 (Webkit Webview) with cordova-ios 4.0.1 and I have a issue.

I have several assets that I need to add remotely on my app. It used to work great but iOS9 (and/or wkwebview) seems to break it.

The download works fine. The unzip too apparently. But I can't access the assets in it (I get a "Failed to load resource")

Here is the log:

appPath file:///var/mobile/Containers/Data/Application/AE18194F-1B41-456C-AC93-459387D5D52E/Library/NoCloud/content-sync
startDownload from https://www.myawesomedomain.com/content-sync.zip
Received challenge for host www.myawesomedomain.com
Task: /var/mobile/Containers/Data/Application/AE18194F-1B41-456C-AC93-459387D5D52E/Library/content-sync.zip completed successfully
unzipped path /var/mobile/Containers/Data/Application/AE18194F-1B41-456C-AC93-459387D5D52E/Library/NoCloud/content-sync

Everything works fine on Android though.

Is there a way to check if the images are indeed here ? I have no idea how to debug this.

Thanks a lot

mparpaillon commented 8 years ago

Ok I checked the downloaded datas and everything is there. So I guess it only fails when I try to access the file via its URI file:///var/mobile/Containers/Data/Application/AE18194F-1B41-456C-AC93-459387D5D52E/Library/NoCloud/content-sync/my-file.png

imhotep commented 8 years ago

@mparpaillon you should be able to use Sync.loadUrl("file://...") to load your assets. Install plugin using:

cordova plugin add https://github.com/phonegap/phonegap-plugin-contentsync.git

Let me know if it works for you

mparpaillon commented 8 years ago

Oh nice. Could you give me an example of how to use it in a img tag or a background-image ? I'm not sure I understand how to use it :)

Thanks a lot

mparpaillon commented 8 years ago

Haha there's a little typo in your condition I think

if(url) {
    throw new Error('URL is required.');
}