简体   繁体   English

科尔多瓦将图像存储在本地存储中

[英]Cordova storing images in localstorage

I'm creating a cordova app targetting iOS 6.1 and above. 我正在创建针对iOS 6.1及更高版本的cordova应用。 I need to store json data with images. 我需要将json数据与图像一起存储。 As you guessed the images will be stored as base-64 string. 如您所料,图像将存储为base-64字符串。 I need to store dozens of images and in this case is it better go with localStorage or filestorage. 我需要存储数十个图像,在这种情况下,最好使用localStorage或filestorage。 Is there any size limit in Cordova's localstorage? Cordova的本地存储有大小限制吗?

Cordova uses browser's native implementation of localStorage where available, using its own only where localStorage is not available. Cordova在可用的情况下使用浏览器的localStorage本地实现,仅在localStorage不可用的情况下使用其自己的实现。 Generally, limit of localStorage is unknown as it depends on browser and user settings. 通常, localStorage限制是未知的,因为它取决于浏览器和用户设置。 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. 规格中有5 MB的任意限制,等于2.5 MB的2字节编码文本,大约等于1.8 MB的二进制数据。

FileStorage seems more suitable for your needs. FileStorage似乎更适合您的需求。

Using localForage, you could store the image as a base64 string or even a Blob. 使用localForage,您可以将图像存储为base64字符串甚至Blob。
http://mozilla.github.io/localForage/ http://mozilla.github.io/localForage/
https://developer.mozilla.org/en-US/docs/Web/API/Blob https://developer.mozilla.org/en-US/docs/Web/API/Blob

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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