localstorage 存储草稿图片,如何实现?

前端梁
  • 841

我正在使用backbone.localstorage 用来做 草稿功能,可以保存文字,但是如何将图片保存到草稿中呢?如果使用base64的话,大图片比如10M就不好处理了,大家有没有什么建议?

回复
阅读 3.5k
2 个回答
✓ 已被采纳

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.

存url,再获取,没有网络给默认的

你知道吗?

宣传栏