File and Directory Entries API
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 and Directory Entries 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.
Because this is a non-standard API, whose specification is not currently on a standards track, it's important to keep in mind that not all browsers implement it, and those that do may implement only small portions of it. Check the Browser compatibility section for details.
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.
The Firefox implementation of the File and Directory Entries API is very limited; there is no support for creating files. Only for accessing files which are selected by the user in a file
<input> element (see
HTMLInputElement as well) or when a file or directory is provided to the Web site or app using drag and drop. Firefox also does not implement the synchronous API. Check the browser compatibility for any part of the API you use carefully, and see File and Directory Entries API support in Firefox for more details.
The asynchronous API should be used for most operations, to prevent file system accesses from blocking the entire browser if used on the main thread. It includes 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.
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.
|File and Directory Entries API
|Draft of proposed API
This API has no official W3C or WHATWG specification.
|Chrome for Android
|Firefox Mobile (Gecko)
 Firefox 50 introduces partial support for the File and Directory Entries API. Be sure to check the compatibility tables for individual interfaces and methods before using them, to ensure that they're supported, before you use them. The API can be disabled by setting the value of the preference
- Introduction to the File and Directory Entries API
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.