Best way to store files in the browser (non-disk)

Skip to first unread message

Mohamad Bazzi

Nov 29, 2021, 7:56:14 PM11/29/21
to Chromium Extensions
In my chrome extension, I would like to store files in the browser (from background script) but not on disk, as I would like to read and erase the files quickly. Is the best solution to use blob URLs? If so, how much data can I store as blob URLs? Or should I just store the file contents in an array in the background script?


Nov 30, 2021, 9:09:46 AM11/30/21
to Chromium Extensions,
Blob-urls don't survive extension restarts.
To persist between restarts you have to use
After reading data from you may construct a data-url [1] or blob-url from it.

Simeon Vincent

Nov 30, 2021, 4:37:58 PM11/30/21
to Chromium Extensions, ilyaigpetrov,
Alternatively you can use IndexedDB to store files. Personally I'd recommend using IndexedDB because it's a web platform feature and there are a number of articles and libraries out there covering how to use it to store files. In fact, just now when I did a Google search for "indexeddb file storage" I found Robert Nyman's Storing images and files in IndexedDB post on the Mozilla Hacks blog.

Simeon - @dotproto
Chrome Extensions DevRel

Mohamad Bazzi

Dec 1, 2021, 6:33:05 PM12/1/21
to Simeon Vincent, Chromium Extensions, ilyaigpetrov
Reply all
Reply to author
0 new messages