Originally, I made a request to be able to stream chunks of data into the downloads API for the purposes of backing up an indexedDB database to the local disk in a less memory intensive manner. However, after thinking about this further, I’d like to modify this request, for I think there may be a better/more-specific method of accomplishing this task as related to indexedDB only. Access to the download stream isn’t really needed; and it would be preferrable to not have to convert the database to a text file and then “unpack” it back into object stores later to restore it.
If there were database methods (like open, close, delete) of “back-up to disk” and “restore from disk”, that would simply download (with the user’s permission just like any other download) a snap-shot of the SQLite file to the local disk in a form that could be used to restore it back to the page at a later time, the task would be greatly simplified. It would also be very useful if one of these snapshots could be held in a property of an existing indexedDB object store also.
The best method I’ve learned of thus far and have been able to employ is to add the data to an array of blobs, as it is extracted from the database, and then join the blobs together into one giant blob (including a map for unpacking that text file back into object stores and records), before downloading through a data URL. If I understand correctly, the entire database is first held in RAM in the array of blobs and then more RAM is required to join/reduce that array into one giant blob. The RAM is released shortly after the data URL is revoked; in my experience 45 seconds to a minute later. To restore the database, the file has to be read in slices and employ a map to write the slices to the correct object stores. None of this would be necessary any longer.
I’m still very much a novice, but in looking for a “home” or environment in which to run a tool I’ve been working on, it appears that the extension APIs can make use of the browser to function very much like a desktop application for many scenarios and the only negative is saving the users’ work to local disk in the event that the database does not persist for some reason. In my case, there appears to be no added value in using one of the tools that packages a local server and a stripped-down browser together to make it work like a desktop application just to get access to the local disk, when secure extension APIs provide all that is required except a less memory intensive manner of saving the users’ work to disk.