This API is still being developed. It is only available to developers building from trunk.

chrome.fileSystemProvider

Description: Use the chrome.fileSystemProvider API to create file systems, that can be accessible from the file manager on Chrome OS.
Availability: Not fully implemented. You must build Chromium from source to try this API. Learn more.
Permissions: "fileSystemProvider"

Manifest

You must declare the "fileSystemProvider" permission in the extension manifest to use the File System Provider API. For example:

      {
        "name": "My extension",
        ...
        "permissions": [
          "fileSystemProvider"
        ],
        ...
      }
      

Overview

File System Provider API allows extensions to support virtual file systems, which are available in the file manager on Chrome OS. Use cases include decompressing archives and accessing files in a cloud service other than Drive.

File handlers

Provided file systems can either provide file system contents from an external source (such as a remote server), or using a local file (such as an archive) as its input.

In the second case, the providing extension should have a file_handlers manifest entry in order to be launched when the file is selected in the file manager. When the extension is executed with a file to be handled, it has to mount a file system and start serving contents from the provided file.

Life cycle

Provided file systems once mounted are remembered by Chrome and remounted automatically after reboot or restart. Hence, once a file system is mounted by a providing extension, it will stay until either the extension is unloaded, or the extension calls the unmount method.

In case of acting as a file handler, the handled file may need to be stored to access it after either a reboot, or suspending and resuming an event page of the providing extension. In such case chrome.fileSystem.retainEntry and chrome.fileSystem.restoreEntry should be used.

Summary

Types
ProviderError
EntryMetadata
CreateDirectoryRequestedOptions
DeleteEntryRequestedOptions
CreateFileRequestedOptions
CopyEntryRequestedOptions
MoveEntryRequestedOptions
TruncateRequestedOptions
WriteFileRequestedOptions
AbortRequestedOptions
Methods
mount chrome.fileSystemProvider.mount(object options, function successCallback, function errorCallback)
unmount chrome.fileSystemProvider.unmount(object options, function successCallback, function errorCallback)
getAll chrome.fileSystemProvider.getAll(function callback)
Events
onUnmountRequested
onGetMetadataRequested
onReadDirectoryRequested
onOpenFileRequested
onCloseFileRequested
onReadFileRequested

Types

ProviderError

Error codes used by providing extensions in response to requests. For success, OK should be used.
Enum
"OK", "FAILED", "IN_USE", "EXISTS", "NOT_FOUND", "ACCESS_DENIED", "TOO_MANY_OPENED", "NO_MEMORY", "NO_SPACE", "NOT_A_DIRECTORY", "INVALID_OPERATION", "SECURITY", "NOT_A_FILE", "NOT_EMPTY", "INVALID_URL", or "IO"

EntryMetadata

properties
boolean isDirectory

True if it is a directory.

string name

Name of this entry (not full path name).

double size

File size in bytes.

Date modificationTime

The last modified time of this entry.

string (optional) mimeType

Mime type for the entry.

CreateDirectoryRequestedOptions

properties
string fileSystemId
integer requestId
string directoryPath
boolean exclusive
boolean recursive

DeleteEntryRequestedOptions

properties
string fileSystemId
integer requestId
string entryPath
boolean recursive

CreateFileRequestedOptions

properties
string fileSystemId
integer requestId
string filePath

CopyEntryRequestedOptions

properties
string fileSystemId
integer requestId
string sourcePath
string targetPath

MoveEntryRequestedOptions

properties
string fileSystemId
integer requestId
string sourcePath
string targetPath

TruncateRequestedOptions

properties
string fileSystemId
integer requestId
string filePath
double length

WriteFileRequestedOptions

properties
string fileSystemId
integer requestId
integer openRequestId
double offset
double length
ArrayBuffer data

AbortRequestedOptions

properties
string fileSystemId
integer requestId
integer operationRequestId

Methods

mount

chrome.fileSystemProvider.mount(object options, function successCallback, function errorCallback)

Mounts a file system with the given fileSystemId and displayName. displayName will be shown in the left panel of Files.app. displayName can contain any characters including '/', but cannot be an empty string. displayName should be descriptive but doesn't have to be unique. Duplicate display names are uniquified by adding suffix like "(1)" in the Files app UI.

If a file system with the passed fileSystemId is already mounted by this extension, then errorCallback will be called with ProviderError.EXISTS value. The fileSystemId must not be an empty string.

Parameters
object options
string fileSystemId
string displayName
function successCallback

Callback to receive the result of mount() function.

Parameters
DOMError error
function errorCallback

Callback to handle an error raised from the browser.

The errorCallback parameter should be a function that looks like this:

function(DOMError error) {...};
DOMError error

unmount

chrome.fileSystemProvider.unmount(object options, function successCallback, function errorCallback)

Unmounts a file system with the given fileSystemId. It should be called after onUnmountRequested is invoked. Also, the providing extension can decide to perform unmounting if not requested (eg. in case of lost connection, or a file error). If there is no file system with the requested id, or unmounting fails, then the errorCallback will be called.

Parameters
object options
string fileSystemId
function successCallback

Callback to receive the result of unmount() function.

Parameters
DOMError error
function errorCallback

Callback to handle an error raised from the browser.

The errorCallback parameter should be a function that looks like this:

function(DOMError error) {...};
DOMError error

getAll

chrome.fileSystemProvider.getAll(function callback)

Returns all file systems mounted by the extension.

Parameters
function callback

Callback to receive the result of getAll() function.

The callback parameter should be a function that looks like this:

function(array of object fileSystems) {...};
array of object fileSystems

Properties of each object

string fileSystemId
string displayName

Events

onUnmountRequested

Raised when unmounting for the file system with the fileSystemId identifier is requested. In the response, the unmount API method should be called together with successCallback . If unmounting is not possible (eg. due to a pending operation), then errorCallback must be called.

addListener

chrome.fileSystemProvider.onUnmountRequested.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function(object options, function successCallback, function errorCallback) {...};
object options
string fileSystemId
integer requestId
function successCallback

Callback to be called by the providing extension in case of a success.

function errorCallback

Callback to be called by the providing extension in case of an error.

The errorCallback parameter should be a function that looks like this:

function( ProviderError error) {...};
ProviderError error

onGetMetadataRequested

Raised when metadata of a file or a directory at entryPath is requested. The metadata should be returned with the successCallback call. In case of an error, errorCallback must be called.

addListener

chrome.fileSystemProvider.onGetMetadataRequested.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function(object options, function successCallback, function errorCallback) {...};
object options
string fileSystemId
integer requestId
string entryPath
function successCallback

Success callback for the onGetMetadataRequested event.

Parameters
EntryMetadata metadata
function errorCallback

Callback to be called by the providing extension in case of an error.

The errorCallback parameter should be a function that looks like this:

function( ProviderError error) {...};
ProviderError error

onReadDirectoryRequested

Raised when contents of a directory at directoryPath are requested. The results should be returned in chunks by calling the successCallback several times. In case of an error, errorCallback must be called.

addListener

chrome.fileSystemProvider.onReadDirectoryRequested.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function(object options, function successCallback, function errorCallback) {...};
object options
string fileSystemId
integer requestId
string directoryPath
function successCallback

Success callback for the onReadDirectoryRequested event. If more entries will be returned, then hasMore must be true, and it has to be called again with additional entries. If no more entries are available, then hasMore must be set to false.

Parameters
array of EntryMetadata entries
boolean hasMore
function errorCallback

Callback to be called by the providing extension in case of an error.

The errorCallback parameter should be a function that looks like this:

function( ProviderError error) {...};
ProviderError error

onOpenFileRequested

Raised when opening a file at filePath is requested. If the file does not exist, then the operation must fail.

addListener

chrome.fileSystemProvider.onOpenFileRequested.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function(object options, function successCallback, function errorCallback) {...};
object options
string fileSystemId
integer requestId
string filePath
enum of "READ", or "WRITE" mode
function successCallback

Callback to be called by the providing extension in case of a success.

function errorCallback

Callback to be called by the providing extension in case of an error.

The errorCallback parameter should be a function that looks like this:

function( ProviderError error) {...};
ProviderError error

onCloseFileRequested

Raised when opening a file previously opened with openRequestId is requested to be closed.

addListener

chrome.fileSystemProvider.onCloseFileRequested.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function(object options, function successCallback, function errorCallback) {...};
object options
string fileSystemId
integer requestId
integer openRequestId
function successCallback

Callback to be called by the providing extension in case of a success.

function errorCallback

Callback to be called by the providing extension in case of an error.

The errorCallback parameter should be a function that looks like this:

function( ProviderError error) {...};
ProviderError error

onReadFileRequested

Raised when reading contents of a file opened previously with openRequestId is requested. The results should be returned in chunks by calling successCallback several times. In case of an error, errorCallback must be called.

addListener

chrome.fileSystemProvider.onReadFileRequested.addListener(function callback)
Parameters
function callback

The callback parameter should be a function that looks like this:

function(object options, function successCallback, function errorCallback) {...};
object options
string fileSystemId
integer requestId
integer openRequestId
double offset
double length
function successCallback

Success callback for the onReadFileRequested event. If more data will be returned, then hasMore must be true, and it has to be called again with additional entries. If no more data is available, then hasMore must be set to false.

Parameters
ArrayBuffer data
boolean hasMore
function errorCallback

Callback to be called by the providing extension in case of an error.

The errorCallback parameter should be a function that looks like this:

function( ProviderError error) {...};
ProviderError error