localStorage store large size data

后端 未结 2 1103
北恋
北恋 2021-01-11 23:44

I want to use localStorage to store large amount of data(like 800GB), according to http://arty.name/localstorage.html and also I\'m using Firefox, I changed my localStorage

相关标签:
2条回答
  • 2021-01-12 00:14

    You can't! Usual limit is 5 mb.

    Some browser such as Opera allow you to adjust the size, but this is purely dependent on browser and is a user initiated action, not a programmable one.

    And even if you could, remember that localStorage can only store strings so anything else need to be stringified first. That together with this being an key/value storage array you will run into pretty poor performance at the end.

    If you need large storage capacity, look into File API instead. This is made to work with large files (Blobs) and you can store anything as a Blob.

    800 Gb is a large size and File API can only work as fast as the file system (at best, more likely a bit slower as it is sandboxed, ie. not a pure file system).

    More about File System API (Note: discontinued as of 4/2014):
    http://www.w3.org/TR/file-system-api/

    Tutorial:
    http://www.html5rocks.com/en/tutorials/file/dndfiles/

    Blob:
    https://developer.mozilla.org/en-US/docs/Web/API/Blob

    Update As the Filesystem API has been discontinued there are essentially only two options left (besides from storing data to the server):

    • Indexed Database API aka Indexed DB (recommended)
    • Web SQL (deprecated but still supported in browsers such as Safari)

    Also these are initially limited in size by the browser. It is possible to request a larger quote which the user is asked to accept.

    See more details about this API here:
    http://www.w3.org/TR/IndexedDB/

    0 讨论(0)
  • 2021-01-12 00:26

    There is LargeLocalStorage which provides a cross-browser way to storage large amounts of data locally. You can store binary data or strings.

    LargeLocalStorage uses the FilesystemAPI on Chrome, IndexedDB in IE and Firefox and WebSQL in Safari.

    0 讨论(0)
提交回复
热议问题