How is HTML5 WebStorage data physically stored? - html

In using the HTML5 WebStorage functionality, I know that certain browsers, like Chrome, have developer tools that enable users to browse thru the contents of their WebStorage for debugging and trouble-shooting purposes.
I was wondering if it is possible to view the contents of web storage in the file system. Is this content stored in text files on the file system that are in some standard location? Or is this data stored in some proprietary binary format by the various browsers and is not designed to be accessible or viewable by browsing the file system?
My motivation for asking this question is to see if you can view the content of WebStorage on the file system as an aid to development and debugging, and also just out of curiosity too see how this data is actually stored.
Thanks.

Chrome uses SQLite for LocalStorage.
I confirmed this by going to AppData\Local\Google\Chrome\User Data\Default\Local Storage on my local PC and viewing the contents of a file. The files start with "SQLite format 3" when viewed via a text editor. You will need a SQLite database viewer to view the data.

On Mac OS X, this was at ~/Library/Application Support/Google/Chrome/Default/Local Storage
I used the Command Line Shell For SQLite to look around. Assuming www.example.com was a real site, you can run these commands:
$ sqlite3 http_www.example.com_0.localstorage
sqlite> .tables
ItemTable
sqlite> .schema
CREATE TABLE ItemTable (key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB NOT NULL ON CONFLICT FAIL);
sqlite> select * from ItemTable;
stringkey|value
jsonkey|{"key","value"}
sqlite> .exit
See Where does firefox store javascript/HTML localStorage? for the Firefox storage location.  Chrome uses individual sqlite files per hostname and protocol, where Firefox uses a single webappsstore.sqlite file with the reversed hostname and protocol in a scope column.
See Where the sessionStorage and localStorage stored? for the Opera storage location. Opera uses an XML index file and individual XML files for the Base64 encoded data.

Just wanted to contribute for IE 11.
The localstorage is stored in: C:\Users[YOUR USER ACCOUNT]\AppData\LocalLow\Microsoft\Internet Explorer\DOMStore
However, it is hidden by default. To show this folder you have to:
Folder Options --> Uncheck "Hide protected operating system file"
Back to folder, you will see some sub folder inside. Go to each folder will see some XML files according for websites.

Related

Automatically format .csv file upon download?

I have a form that will open a file based on user's selections. A few files are .csv and those files open up in Excel, as expected. However, everything is placed into one cell... I know that there is a way to manually configure it so that the | or , are delimiters, but is there a way to set it so that Excel will automatically set the | as a delimiter?
Thank you in advance!
Because you use the word "download" and your question is tagged "html", I assume that the user interacts with a web form rather than a desktop form.
In that case, it's the web browser that decides what to do with the file. If the browser recognizes the content-type of the response as something it can handle natively (e.g. "text/plain" or "image/jpeg") then it may open the file and display it directly.
However if the content-type is not something it knows how to deal with (which is likely the case with "application/csv"), then it will download the file and ask the operating system to open it. At that point, the filename assigned to the file (which can be set via the HTTP response) may come into play.
On a Windows machine, the operating system maintains a list of file extensions and actions associated with those extensions. When you install Excel, that will normally make Excel the default "open" action for files with the ".csv" extension. That's why double-clicking on a ".csv" file opens in Excel, and also why it may open in Excel if you download it from a website. (If you didn't have Excel, it may simply ask you what program you want to use).
This is a long-winded way of saying that if you had control over the user's machine you could give the file a different file extension and then associate that extension with an action that did something different. But, I assume that you probably don't have that sort of control unless you're dealing only with in-house users, and anyway it would not be a trivial thing to achieve.
I don't think that there's any way to communicate to Excel via the command line that it should use a particular delimiter when opening a CSV file, and that - unfortunately - is the mechanism by which the operating system will ultimately open the file.
It is possible to control what Excel uses as the default delimiter for all CSV files (see https://superuser.com/a/606274/18472) but again that would require you to change the system-wide settings on your users' machines, which I imagine would not be possible.

In what form does Chrome save local storage?

I am trying to figure out where and how does Chrome save local storage.
I found the following folder (in my home folder) that seems to contain the local storage:
\AppData\Local\Google\Chrome\User Data\Default\Local Storage
In this folder I see files that corresponds to different URLs (the files contain URLs in their names). For each URL I see two types of files:
LOCALSTORAGE file
LOCALSTORAGE-JOURNAL file
I am interested in local storage of one particular web site. For this web-site the LOCALSTORAGE file contains only 6KB and the LOCALSTORAGE-JOURNAL contains nothing (0 KB).
On the other hand, when I open the web site of interest in Chrome and then press F12 I see in the local storage 6 different URL and if I click on one of them I see key-value pairs.
So, what I see in the folder and in the Chrome development tool is not consistent. Why is that? How can one find content of local storage in the directories? Or is it impossible?
The file is in SQL Lite format. Install SQL Lite, then type the following commands:
cd %LocalAppData%\Google\Chrome\User Data\Default\Local Storage
sqlite3 *filename*
select * from ItemTable;
.quit
The ItemTable table contains key-value pairs, the semantics of which depend on the individual website.
see the description of localstorage file here
it says : The extension LOCALSTORAGE indicates an application support file created by the web browsers using WebKit, such as Google Chrome and Apple Safari. These files store browser settings or local data for a browser extension, and enables extensions to store a local cache of user data saved in an SQLite database format.
You can browse localstorage files by a sql-lite browser, such as the open source program called sql-lite database browser

Open binary file from HTML5 offline web application

I'm able to use HTML5 standard File API and IndexedDB to store large binary files in the browser.
However, when offline, I need to be able to open these files. Using data URLs works great for small files, but none of the browsers support 10Mb file opening through data URL. Is there any other solution, except for non-standard window.webkitRequestFileSystem?
I've actually found an answer here: https://developer.mozilla.org/en/docs/Web/API/Blob.
It is possible to save result of FileReader.readAsArrayBuffer in IndexedDB. When offline, it is possible to create a blob from this typed array and then create data URL to be passed to window.open function. Works with large files!

Is it possible **to change an .sql file extension to like .myname** and still the software like wamp or sqlite can still read it?

Is it possible to change an .sql file extension to like .myname and still the software like wamp or sqlite can still read it??
-I was just thinking of the possibilities that changing the file extension to something custom could add to db security.
Using sqlite3 in Python you can select any arbitrary file extension (as long as [a-zA-Z]{1,...}) without hindering the module in accessing the database-file.
Note, however, that changing a default file-extension to a different arbitrary one does not increase (or decrease for that matter) security of the data stored in the database in any way.
You'd have to test if other (SQLite-)implementations allow custom extensions as well, but either way, it would have not impact whatsoever on security.
So long as the software in question does not limit itself to only recognizing files ending ".sql", it makes no difference whatsoever.
A file extension is just a label - they do not affect the actual physical contents of a file in any way, and an SQL file is just a text file. That .sql extension is really more of a user aid than a software aid - whilst software will use it as a filter (such as only showing .doc files by default on Word's Open dialog), if you tell a program to treat file X as a file of format Y then it will attempt to read it as a Y-formatted file, regardless of extension.
You could change it to .txt and (under Windows) it would open in Notepad instead when double-clicked, or .doc and it would open in Word (probably incorrectly, as Word would attempt to parse it as a Word-formatted file, not a plain text file). The actual contents of the file are completely unaffected.
You could change the .sql to .txt or .doc or .bmp or .wahoo or anything (or even remove the extension entirely), it will still be readable by WAMP etc.
It will have absolutely zero effect on security.

Temporary file handle storage in HTML5

Is it possible to obtain file handles in HTML5 and store it as a blob in webDB for upload later?
(Upload selected images when the 3G network is available again, without re-selecting the files.)
The HTML5 will be loaded from the local client device and
action="http://.../insert.jsp"
be used to upload the files to the server.
Any help or ideas will be very useful.
C-:
Any File object can be converted to an URL.
It is simple to do by using object URLs as described by:
https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications
(I still have to confirm that the URLs remain valid across sessions.)
And it does not remain valid across sessions in Chrome!