write a local file using Javascript with Chromium and the File API

709 views
Skip to first unread message

JeanMarc

unread,
Apr 6, 2012, 10:24:39 PM4/6/12
to Chromium HTML5
I wrote a web-app for Chrome that works offline, and uses SQLite and
Javascript wrapper. The web-app creates a database and populates it
with values from the user. One of the issue I face is that if the user
clear the Chrome cache, the sqlite file that contains the database
information is deleted. I would like to allow the user to backup the
sqlite file in a local folder, so it can be restored. Most of the info/
codes I have found that uses File API is for Chrome Extension.
However, I have no idea if I can use File API for a offline web-app
to backup a sqlite file. I'd appreciate some suggestions.

Eric Bidelman

unread,
Apr 7, 2012, 1:53:17 PM4/7/12
to JeanMarc, Chromium HTML5
Hi Jean,

Backing up a websql db for a user to download can be done with the
File APIs, a[download]. The example on the following page creates a .txt file
from a <textarea>, then uses window.URL.createObjectURL() and the
a[download] attr to let the use download what they've written:

http://updates.html5rocks.com/2011/08/Downloading-resources-in-HTML5-a-download

You can take a similar approach with pulling data from websql, and saving it
to a file.


--
You received this message because you are subscribed to the Google Groups "Chromium HTML5" group.
To post to this group, send email to chromiu...@chromium.org.
To unsubscribe from this group, send email to chromium-html...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-html5/?hl=en.




--
Eric Bidelman | Senior Developer Programs Engineer | e.bid...@google.com 
Reply all
Reply to author
Forward
0 new messages