Need advice on app with potentially large images

Hello. My app will potentially use big beautiful images.

Instead of releasing the app with those images I was thinking to downloand them using cordova file transfer and then save them to device.

Is this a good idea? How would I remove those images when app gets uninstalled?

Ok after a brief investigation it looks liek you cannot save files to APP’s directory on iOS, so this means I will have to clean directory myself if I create it outside of apps directory. I will try storing images in localstorage as base64 instead…

You should be able to! I’ve seen other people use the File API’s (i have not used them) to do similar things.

Dig deeper into the file api plugins with cordova and see what you find, the local storage is limited to 5mb, so if you’re b64ing those and then saving them, it probably won’t work since it sounds like they are big images. How big are they?

To be honest, 90% of people will have access to wifi or have a data plan that doesn’t care if they download large apps. You could even be on the high mark of 100mb for the app and you’d be relatively okay. The asphalt racing game is like 1.2GB haha.

Hey, thanks for the reply :smile:

  • Well as far as I know you can request a permission from user to have around 100mb of localstorage on his device.

What I don’t like about File Api idea is that on iOS and Android different folders have different write permissions, so on Android I can save images to APP’s directory, so when app is uninstalled, images will go away also, while on iOS app’s directory is read-only, so I have to write filed to Documents, and do manual checks in case user or OS deletes them. Another annoyance with this approach is that I will have to check for disk free space on device, then go to my server, calculate how much space I will need to store all images and then prompt user to free up the space if it’s not enough.

Taking this in account, I think I will spend one more day trying to do it with File and FileTransfer cordova plugins, and if it doesn’t work nicely will have to just have images with the app during initial installation.

1 Like

I used angular-imgcache.js in the end, as it is handling all the r-w directories inconsistencies for me.

Yep it is a good choice.

it uses the imgCache module, which provides cordova support.
It downloads the files in the “app-directory” so if you clear app-data or uninstall the app the files will be gone, too.

And it provides the possibiity to clear the files within your appcode.

Only missing thing for me is, to be table to have multiple cache-folders. So i could groupe my files logically and clear only parts of images instead of clear everything.

base64 files are a very bad idea especially for huge images.
You produce a very big DOM and get ~30% data overhead.

1 Like