File System API

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The File System API simulates a local file system that web apps can navigate within. You can develop apps which read, write, and create files and/or directories in a virtual, sandboxed file system.

Two very similar APIs exist depending on whether you desire asynchronous or synchronous behavior. The synchronous API is indended to be used inside a Worker and will return the values you desire. The asynchronous API will not block and functions and the API will not return values; instead, you will need to supply a callback function to handle the response whenever it arrives.

Asynchronous API

The asynchronous API has the following interfaces:

  • LocalFileSystem has two global methods that lets you request access to a sandboxed file system: requestFileSystem() and resolveLocalFileSystemURL().  The methods are implemented by both the window object and the worker global scope.
  • FileSystem represents a file system. The object is your gateway to the entire API.
  • Entry represents an entry in a file system. The entry can be a file or a directory.
  • DirectoryEntry represents a directory in a file system. 
  • DirectoryReader lets you read files and directories in a directory.
  • FileEntry represents a file on a file system.
  • FileError is an error that you might encounter while using the asynchronous methods.

Synchronous API

The synchronous API is for use with WebWorkers. Unlike the asynchronous API, the synchronous API does not use callbacks because the API methods return values.

  • LocalFileSystemSync has two global methods that lets you request access to a sandboxed file system: requestFileSystemSync() and  resolveLocalFileSystemSyncURL(). The methods are implemented by the worker object.
  • FileSystemSync represents a file system.
  • EntrySync represents an entry in a file system. The entry can be a file or a directory.
  • DirectoryEntrySync represents a directory on a file system. 
  • DirectoryReaderSync lets you read files and directories in a directory.
  • FileEntrySync represents a file on a file system.
  • FileException is an error that you might encounter while using the synchronous methods.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Asynchronous API 13 webkit No support No support No support No support
Synchronous API 13 webkit No support No support No support No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Asynchronous API No support (Yes) webkit No support No support No support No support
Synchronous API No support (Yes) webkit No support No support No support No support

See also

Document Tags and Contributors

 Contributors to this page: alexisdelee, teoli, Jeremie, cvrebert, kscarfone, boa0332, ScottMichaud, Sheppy
 Last updated by: alexisdelee,