localstorage 存储草稿图片,如何实现?
我正在使用backbone.localstorage 用来做 草稿功能,可以保存文字,但是如何将图片保存到草稿中呢?如果使用base64的话,大图片比如10M就不好处理了,大家有没有什么建议?
kulo嘉
10 years ago
Answers
There's no workaround. Storage quota is a hard limit.
However, for binary data I would recommend
IndexedDB
instead of
localStorage
, for several reasons:
- You can save binary data directly (no need to convert to base64), which saves 33% of quota.
- This also helps to get rid of the performance overhead of conversion.
-
According to
a test
, in some browsers (e.g. Firefox), IndexedDB have more storage quota compared to
localStorage
. - IndexedDB provides an asynchronous API, which is important when you read a big chunk of data that takes time.
seoul
answered 10 years ago