I'm planning to implement "Recenty Opened Files" functionality in my webapp and I'm trying to decide which HTML5 technologies to use. The most important thing here is a fact, that I can't just save a filepath to the file and then reopen it. Due to security reasons, reading a file must be initiated by user action (choosing a file from input or dragging and dropping it). So the only option is to save the whole file in cache. Here are my options:
A. LocalStorage
Store the JSON object like this:
{ "recent": [ {}, {},..., {} ] }
where each
{}
is a JSON file descriptor looking like this:{ "filename": "blah", "type" : "txt", "chunks": ['"3bce4931-6c75-41ab-afe0-2ec108a30860"',...] }
where each chunk is a key in localstorage to lzw-encoded data chunk. Each chunk is data from blobfile, obtained while reading a file.
I know, that localstorage can store only string, not JSON, but it's easy to serialise. The problem with this apprach is limited size of local storage and synchronous API, which can slow down whole application while reading a chunk of data from the file.
B. IndexedDB
I just started to read about this HTML5 feature but apparently it has asynchroinous API and is able to store whole fileBlob object. I don't know size limitations though. Unfortunately browser support is very limited and API seems to be horrible.
Question is:
I can't find any implementation of Rcenty Opened Files using either of technologies. Do you have? Any suggestions, known gotchas?