Home > Articles > Home & Office Computing > The Web/Virtual Worlds/Social Networking

  • Print
  • + Share This
Like this article? We recommend Complementing the File API

Complementing the File API

Part 1 of this series introduced HTML5's File API, which is useful for reading files from the local filesystem. While looking for a better solution for saving canvas content to a file, I encountered HTML5's File Writer API, which is useful for writing content to files in the local filesystem.

The World Wide Web Consortium's (W3C's) File API: Writer document describes the File Writer API. Although none of the browsers referred to in this series implements this API, the File Writer API will probably be supported in the future.

The File Writer API consists of the following components:

  • A BlobBuilder DOM interface that enables the creation of a Blob object from a string—I discuss Blob in Part 1 of this series.
  • A FileSaver DOM interface that provides methods for writing a Blob object to a file, and provides an event model to monitor the progress of those writes.
  • A FileWriter DOM interface that extends FileSaver with a richer set of output options (such as providing the ability to seek to a specific offset within the file at which the next write will occur).
  • A FileWriterSync DOM interface that serves as the synchronous counterpart to FileWriter, in much the same way that FileReaderSync serves as the synchronous counterpart to FileReader (see Part 1).

The W3C's File API: Writer document provides examples that demonstrate the File Writer API; I refer you to those examples to learn more about using this API. Keep in mind that the File Writer API might change somewhat in the future, and might possibly merge with the File API.

  • + Share This
  • 🔖 Save To Your Account