How to implement downloadable assets for offline use

I was wondering how I could give my users the option to choose which images of my app they want to download, so my users would not require an internet connection all the time to see them. This way the users can choose how much local storage they want to invest in to the app.
Example: If the user has an Internet connection he can download an image by clicking a button. If he goes offline then and a downloaded image exists it is loaded from the filesystem rather than being pulled from a website.
I tried to implement such an algorithm but I never managed to load an image from the local Android filesystem using Ionics FileTransfer system.
Do you have any ideas on how to implement this?

Hi,

You can use services workers to do what you want. I never did image caching but you can find some informations here :


https://developers.google.com/web/ilt/pwa/lab-caching-files-with-service-worker

If you don’t succeed with a service worker you can try to save your files with the File plugin :

Then when you display an image, create a service/directive to check if a file existe before using a remote url.

Thank you so much for the help!