Book Review: “Using the HTML5 Filesystem API” by Eric Bidelman

Review:

4of5stars

“Using the HTML5 Filesystem API” is a good read. It’s small, but concise, and the perfect size (for me). The book covers the evolving specification that is the HTML5 FileSystem API. It isn’t implemented in every browser but does have an implementation in Google Chrome. (The author works for Google.) The HTML5 FileSystem allows browser-based apps to read & write files and directories in a sand-boxed way on users’ computers. It’s sand-boxed in that my app can’t access the file system of your app. The book covers the usual file system “stuff”: how to create a file, how to write to a file, how to read from a file, etc. Most importantly, there are appropriate code samples, because anyone that’s looking into using this API will want to see/copy code.

Overall, for an API book, I think this is the perfect amount of detail and examples. But because there is also great, free information at HTML5Rocks.com, and because the specification is still evolving, I hesitate to say you should go out and buy this. If you need to learn the API soon, and you like learning from books, then by all means, this book is worth reading.

Overview:

Ch. 1 – Introduction – Introduces the HTML5 Filesystem API that is an evolving specification. The API is a way for web apps/sites to write to the user’s file system in a sand-boxed way.

Ch. 2 – Storage and Quota – Describes the storage types: Temporary, Persistent, and Unlimited (Chrome – only) and the properties of those types.

Ch. 3 – Getting Started – Shows you how to start programming the FileSystem API. You use window.requestFileSystem(type, size, successCallback, opt_errorCallback) to get a local, sand-boxed file system for your app; and in some cases you need to use window.webkitStorageInfo.requestQuota(TYPE, SIZE, callback) to  get permission to request the storage.

Ch. 4 – Working with Files – Create, read, write, remove, and import are all covered; as are ways to get files into your browser, via drag-drop, file input dialog, and XMLHttpRequest. Chrome, Safari 5, and Firefox 4 support dragging files from the desktop and dropping them on the browser.

Ch. 5 – Working with Directories – Like the chapter on files, this shows how to create, list, and remove directories.

Ch. 6 – Copying, Renaming, and Moving Entries – Files and directories both inherit from the same super class, Entry, so this chapter is about both files and directories. Folders are always copied recursively.

Ch. 7 – Using Files – Discusses how you can actually use files in your HTML5 apps. It goes over using them as

  • Filesystem URLs  – filesystem:<ORIGIN>/<STORAGE_TYPE>/<FILENAME>
  • Blob URLs – blob:<ORIGIN>/<UNIQUE_RANDOM_STR>
  • Data URLs – data:<mimetype>[;base64],<data>

Ch. 8 – The Synchronous API – Some HTML5 FileSystem APIs have synchronous counterparts that can be used in Web Workers. This chapter goes over that and discusses the differences with the asynchronous API. There’s a useful example on how to download files in a web worker using XHR2.

References:

Advertisements
This entry was posted in Book Reviews, HTML5, Web Development and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s