Skip to Content
Using the HTML5 Filesystem API
book

Using the HTML5 Filesystem API

by Eric Bidelman
July 2011
Intermediate to advanced
72 pages
1h 13m
English
O'Reilly Media, Inc.
Content preview from Using the HTML5 Filesystem API

Chapter 2. Storage and Quota

The HTML5 Filesystem API gives applications the facility to write and store actual files in JavaScript. That is amazing, but with great power comes great responsibility. Websites now have the potential to store large amounts of binary data on a user’s system. It is important that applications do not abuse such a gift by, for example, eating up large amounts of disk space without the user’s knowledge or consent. The last thing users want is to have 20 GB of data stored on their system just by visiting a URL.

At the time of writing, Chrome has a limited UI settings page for users to manage the storage space for applications that save data on their behalf. It is accessible via PreferencesUnder the HoodAll Cookies and Site Data (or by opening chrome://settings/cookies). Users can only delete data from this menu. As a result of this limited UI, write operations (such as creating a folder and writing to a file) require an application to ask for the estimated size, in bytes, they expect to use. The same practice is true for other offline storage APIs, like WebSQL DB, where one opens a database with a particular size:

var db = window.openDatabase(
  'MyDB',           // dbName
  '1.0',            // version
  'test database',  // description
  2 * 1024 * 1024,  // estimatedSize in bytes (2MB)
  function(db) {}   // optional creationCallback
);

Storage Types

A normal web application can request storage space under two classifications: temporary or persistent. In addition to these types, Chrome Extensions ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

HTML5 Geolocation

HTML5 Geolocation

Anthony T. Holdener
HTML5 Hacks

HTML5 Hacks

Jesse Cravens, Jeff Burtoft
Grid Layout in CSS

Grid Layout in CSS

Eric A. Meyer

Publisher Resources

ISBN: 9781449311384Errata Page