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 Preferences→Under the Hood→All 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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

HTML5 Geolocation

HTML5 Geolocation

Anthony T. Holdener
HTML5 Hacks

HTML5 Hacks

Jesse Cravens, Jeff Burtoft
HTML5 Unleashed

HTML5 Unleashed

Simon Sarris

Publisher Resources

ISBN: 9781449311384Errata Page