-
Notifications
You must be signed in to change notification settings - Fork 32
API Proposal Filesystem
- Dietrich Ayala (dietrich / dietrich@mozilla.com)
- Irakli Gozalishvili (gozala / irakli@mozilla.com)
The FileSystem API provides access to an OS file system, restricted to user-chosen directories.
The Add-on SDK contained numerous options for this functionality in the Low-level API set. TODO: internal fs apis Those were implemented in Firefox on top of a mix of the XPCOM APIs (nsIFile and friends) and OSFile.jsm.
This document is a proposal for offering a similar API for webextensions.
The Extensions team has already approved the inclusion of a Filesystem API, and the implementation of this functionality is tracked in bug 1246236.
This section details a proposed webextensions API for Service Discovery.
The example implementation as a WebExtension Experiment API is in the libdweb repository.
Bug 1215028 briefly discusses implementing the Chrome Apps API for filesystem functionality, and the decision was to not do so.
However, the Chrome Apps documentation for their related APIs states:
Chrome's Filesystem and Sync Filesystem APIs extend the HTML5 FileSystem API.
Related Chrome Apps APIs:
Alex Russel has indicated that some Chrome Apps APIs will be deprecated in favor of PWA APIs, but it's unclear what that yet means for extensions to filesystem functionality.
As we move forward, we should coordinate with our folks like Marcos Caceres who can give guidance on balancing web API compatibility with WebExtension additions as we move forward.
As with most existing webextension APIs, this API will have a new top-level permission, “filesystem”.
That is, the functions outlined below will not appear in an extension’s browser namespace unless the “filesystem” permission is included in the extension manifest.
In this way, a user who installs an extension that uses this API can be offered a prompt (either at install time or at use time, see https://github.com/mozilla/addons/issues/51 for that debate) with a message such as:
“This extension may share your IP address with and/or connect to other computers on the local network, do you want to proceed?”
Note: Granted access will be preserved across sessions, and the WebExtension could mount same directory without prompting a user again.
The methods provided by this API will be in the browser.filesystem namespace. Note that, unlike nearly all other existing webextensions interfaces, this is a brand-new interface, so there is no need to includes these methods in the chrome namespace for compatibility.
The methods under browser.filesystem are:
Method Name | Description |
---|---|
File::close(options) |
|
File::flush(options) |
|
File::stat(options) |
|
File::getPosition(options) |
|
File::setDates(options) |
|
File::read(options) |
|
File::write(options) |
|
File::stat(options) |
|
FileSystem::mount(options) |
|
FileSystem::open(options) |
|
FileSystem::stat(options) |
|
FileSystem::setDates(options) |
|
FileSystem::readFile(options) |
|
FileSystem::writeFile(options) |
|
FileSystem::removeFile(options) |
|
FileSystem::setPermissions(options) |
|
FileSystem::copy(options) |
|
FileSystem::move(options) |
|
FileSystem::createSymbolicLink(options) |
|
FileSystem::exists(options) |
|
FileSystem::watch(options) |
|
FileSystem::createDirectory(options) |
|
FileSystem::removeDirectory(options) |
|
FileSystem::readDirectory(options) |