简体   繁体   中英

Cordova storing images in localstorage

I'm creating a cordova app targetting iOS 6.1 and above. I need to store json data with images. As you guessed the images will be stored as base-64 string. I need to store dozens of images and in this case is it better go with localStorage or filestorage. Is there any size limit in Cordova's localstorage?

Cordova uses browser's native implementation of localStorage where available, using its own only where localStorage is not available. Generally, limit of localStorage is unknown as it depends on browser and user settings. There is an arbitrary limit of 5 MB in specs , which equals 2.5 MB of 2 byte-encoded text, which equals roughly 1.8 MB of binary data.

FileStorage seems more suitable for your needs.

Using localForage, you could store the image as a base64 string or even a Blob.
http://mozilla.github.io/localForage/
https://developer.mozilla.org/en-US/docs/Web/API/Blob

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM