Camera/PhotoLibrary usage, conserving memory for stability, and file URLs

Hi guys, so i have an app in the works that will heavily utilise the camera to take multiple photos - it could be anywhere between 20-30 photos per “journey”, and my experience in the past with Ionic 1 + the camera has been sketchy with even one photo.

Users can create “Journeys”, then store them offline before “publishing” them to the server - so obviously i want data to persist between app usage. I’m intending to use localStorage to avoid having to set up SQLite - oh how i hate SQLite.

So there are multiple questions i have, along with an approach i was going to use but might not. I’ll explain each question as i go along to explain why i’m confused.

  1. Can you store a photo file on the filesystem and display it in the app without having to convert it back to a base64 encoded string?

Or does it not matter? My worry is a user adding photos to the “journey” and adding 5-10 photos of one spot, then will having all those images in memory as base64 strings affect the performance of my app?

If it matters, the user taps “Add point”, which brings up a modal, and from there they can enter details about the point and add photos - and as you add the photos, it displays the thumbnails.

  1. What do you do about potential leftover files in the filesystem?

I would, in my localStorage information, keep track of filenames that i would need to upload to the server come publishing time - but what about any files that are left orphaned by data corruption or crashes - should i worry about them?

  1. As much as i hate SQLite, is it a valid alternative to writing files to the filesystem?

Could i say, create a table that would be used to store these images as base64 encoded strings, then retrieve them from there rather than the filesystem?

Is there a massive speed difference? Are there more limitations? Would i lose metadata?

I’m hoping to create an NPM package after this that simplifies working with images, their storage and retrieval, so your answers will hopefully help me give something back.

Thanks all.

Dan.

I can’t answer all the questions, but as far as 1 goes you should be able to display photos that way with a standard <img> tag.

The most important response I have though, is that it’s best not to use localStorage if you need to persist data.
The biggest reason in a nutshell, is that iOS 8 will sometimes clear localStorage when memory gets low.

Thanks - i’ll try and find something more permanent like PouchDB to store my journey data in.

PouchDB can also store attachments like images.

Thanks! I’ve actually started using this approach now along with the SQLite adapter to avoid storage limits.

I’m having serious problems with crashes - i.e. adding two photographs to a post in the app seems to crash the application if you touch the screen at all while it’s loading a photo into memory.

:frowning: