views:

247

answers:

3

Hi,

I've already managed to save a web page (x/html) successfully, but I'd also like to save the images and mp4 videos that are contained in it, for further visualization in offline mode.

I've got access to the iOS filesystem, so I save the html by obtaining the code through an AJAX request, and later saving it to a file.

I don't really know how to do the same with video and images. I have a server to which I can send queries from my app, so it shows exclusively the content I need to download, with the optimal headers in case its necessary. I just don't know how to "download" it from the client side (Javascript).

Thanks in advance for any help.

+1  A: 

I don't know if you can do anything with video, but images can be cached with phonegap by using the Canvas (you will have problems on a non-phonegap page due to X-domain issues). See Jesse MacFadyen's blog post on how to do this.

Kris Erickson
I had seen that before but I'll have a look right now. Thanks.
StJimmy
A: 

You can only do it natively I'm afraid. I'm doing it through a FileDownload PhoneGap Plugin that I wrote, using NSURLConnection. I pass in the url to download to the plugin through Javascript, and a target location (and it even gives me download progress).

Shazron
Hi, would it be possible for you to share your code? I'd be willing to donate if I can achieve what I'm looking for.
StJimmy
+1  A: 

I wrote a Plugin to download files, code snippets are posted here

http://blog.clearlyinnovative.com/post/1097750723/phonegap-plugin-for-downloading-url

I have not done all the testing on it yet but it basically works and should provide you the basis for rolling your own solution

Aaron Saunders
I'll try it ASAP and reply with feedback. Thanks Aaron!
StJimmy