How can I make a really long string using IndexedDB without crashing the browser? How can I make a really long string using IndexedDB without crashing the browser? javascript javascript

How can I make a really long string using IndexedDB without crashing the browser?


Storing a Blob will use a lot less space and resources as there is no longer a need for conversion to base64. You can even store "text/plain" objects as blobs:

var blob = new Blob(['blob object'], {type: 'text/plain'});var store = db.transaction(['entries'], 'readwrite').objectStore('entries');// Store the object  var req = store.put(blob, 'blob');req.onerror = function(e) {    console.log(e);};req.onsuccess = function(event) {    console.log('Successfully stored a blob as Blob.');};

You can see more info here:https://hacks.mozilla.org/2012/02/storing-images-and-files-in-indexeddb/

Chrome has supported this only since summer of 2014: http://updates.html5rocks.com/2014/07/Blob-support-for-IndexedDB-landed-on-Chrome-Dev so you cannot use this on older versions of Chrome.


I just reopened the Chrome bug which I submitted 2 years ago and created another bug for the FF team, related to the browser crash when creating a large blob. Generating large files shouldn't be a issue for the browsers.