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

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

阅读 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,再获取,没有网络给默认的

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进