Reputation: 7601
I have an offline web application using appcaching. I need to provide it about 10MB - 20MB of data that it will save (client-side) consisting mainly of PNG image files. The operation is as follows:
Here is my current analysis of client-based "databases" that handle binary blob storage
AppCache (via manifest add all the PNG and then update on demand)
WebStorage
PhoneGap & SQLLite
ZIP file
USB or SD card (back to the stone age....)
WebSQL
FileSystem API
IndexedDB
IndexedDB
LawnChair JavaScript wrapper http://brian.io/lawnchair/
IndexedDB JQUERY polyFill https://github.com/axemclion/jquery-indexeddb
idb.filesystem.js http://ericbidelman.tumblr.com/post/21649963613/idb-filesystem-js-bringing-the-html5-filesystem-api
PouchDB JavaScript Library http://pouchdb.com/
NOTE: to see a data:uri encoding of PNG I created an example at: http://jsbin.com/ivefak/1/edit
Desired/Usefull/Uneeded Features
IndexedDB Implementations
My Current Results
FINAL Results posted below as answer
PouchDB now supports binary blobs for all recent browsers (IE, Chrome, Firefox, Chrome on mobile, etc.) as well as many older browsers. That was not the case when I first did this post.
Upvotes: 112
Views: 40373
Reputation: 26110
I have map caching examples(open example, discover regions and zooms, switch offline and discovered regions will availaible).
There are map.js
- map layer for offline tiles, storage.js
- storage implementation based on IndexedDb and WebSQL (but this just test implementation with poor performance).
Additional information about sizes for 2 billion city (Minsk):
Upvotes: 2
Reputation: 7601
Results Offline blob cache for PNG slippy maps
Testing
Fetch from web server
Storage
Display
Results
Upvotes: 27
Reputation: 713
For your requirements I suggest that developing a new polyfill based on two others: FileSystem API to IndexedDB and IndexedDB to WebSQL — is the best option.
The former one will enable support for storing blobs in Chrome (FileSystem API) and Firefox (IndexedDB), while the latter should provide the support for Android and iOS (WebSQL). What is needed is just making these polyfills work together, and I suppose it's not hard.
NB: Since I couldn't find any information on the web about this, you should test if storing blobs using the WebSQL polyfill will work on iOS and Android. It looks like it should work though:
var sql = ["CREATE TABLE", idbModules.util.quote(storeName), "(key BLOB", createOptions.autoIncrement ? ", inc INTEGER PRIMARY KEY AUTOINCREMENT" : "PRIMARY KEY", ", value BLOB)"].join(" ")
Upvotes: 5
Reputation: 3611
A few years back (not exactly the stone age), I was using a signed java applet that would query its server for syncing/updating requirements, download appropriate files from the server and save them on the user's filesystem (not a database). That solution might work for you, although you will need someone to write the applet and sign it. For database solutions, such an applet can use the jdbc available for most databases using localhost on a suitable port (e.g., 3306 for MySQL). I believe the applet tag is deprecated in Html5 but it still works. No experience on Android tablets, so can't comment on that part.
Upvotes: 1