Search code examples
ionic2base64ionic3dexie

insert base64 strings in Dexiejs


I am building an ionic 3 app and I want to set up an upload based on the ImagePicker Cordova plugin. I use Dexie to persist some data, and I wonder if persisting whole base64 strings would be alright. Or is it too heavy?

I want to persist the images chosen with the image picker. When an upload is suspended or stopped i would be able to restart the upload for those.

Anybody using any other type of persistence of Base64 images?

Thank you


Solution

  • It depends on the size of the images. Unless images are larger than 10 megabytes, I think you are safe. There is no direct limit of document sizes in indexedDB except for the quota you are given for the whole db instance, which can vary per platform and can be extended on modern platforms using navigator.storage.persist(). Do not index the property containing the large string though, since it would affect performance badly and eventually trigger unknown bugs.

    In case you target modern platforms (Chromium, Firefox and Safari 10.1), you don't need to convert the images to base64. Instead you can store the binary data directly in a property of type Uint8Array.