Types
ServiceStatus
Enum |
"initializing" ,
"running" ,
"authentication_required" ,
"temporary_unavailable" ,
or "disabled"
|
FileStatus
Enum |
"synced" ,
"pending" ,
or "conflicting"
|
ConflictResolutionPolicy
Enum |
"last_write_win" ,
or "manual"
|
Methods
requestFileSystem
chrome.syncFileSystem.requestFileSystem(function callback)
Returns a syncable filesystem backed by Google Drive. The returned DOMFileSystem
instance can be operated on in the same way as the Temporary and Persistant file systems (see http://www.w3.org/TR/file-system-api/), except that the filesystem object returned for Sync FileSystem does NOT support directory operations (yet). You can get a list of file entries by reading the root directory (by creating a new DirectoryReader), but cannot create a new directory in it.
Calling this multiple times from the same app will return the same handle to the same file system.
Parameters |
function |
callback |
A callback type for requestFileSystem.
The callback parameter should be a function
that looks like this:
function(DOMFileSystem fileSystem) {...};
|
setConflictResolutionPolicy
Sets the default conflict resolution policy for the 'syncable'
file storage for the app. By default it is set to 'last_write_win'
. When conflict resolution policy is set to 'last_write_win'
conflicts for existing files are automatically resolved next time the file is updated. |callback| can be optionally given to know if the request has succeeded or not.
Parameters |
ConflictResolutionPolicy |
policy |
|
function |
(optional)
callback |
A generic result callback to indicate success or failure.
If you specify the callback parameter, it should
be a function that looks like this:
function() {...};
|
getConflictResolutionPolicy
chrome.syncFileSystem.getConflictResolutionPolicy(function callback)
Gets the current conflict resolution policy.
Parameters |
function |
callback |
A callback type for getConflictResolutionPolicy.
The callback parameter should be a function
that looks like this:
function( ConflictResolutionPolicy policy) {...};
|
getUsageAndQuota
chrome.syncFileSystem.getUsageAndQuota(DOMFileSystem fileSystem, function callback)
Returns the current usage and quota in bytes for the 'syncable'
file storage for the app.
Parameters |
DOMFileSystem |
fileSystem |
|
function |
callback |
A callback type for getUsageAndQuota.
The callback parameter should be a function
that looks like this:
function(object info) {...};
object |
info |
integer |
usageBytes |
|
integer |
quotaBytes |
|
|
|
getFileStatus
chrome.syncFileSystem.getFileStatus(Entry fileEntry, function callback)
Returns the FileStatus for the given fileEntry
. The status value can be 'synced'
, 'pending'
or 'conflicting'
. Note that 'conflicting'
state only happens when the service's conflict resolution policy is set to 'manual'
.
Parameters |
Entry |
fileEntry |
|
function |
callback |
A callback type for getFileStatus.
The callback parameter should be a function
that looks like this:
function( FileStatus status) {...};
|
getFileStatuses
chrome.syncFileSystem.getFileStatuses(array of object fileEntries, function callback)
Returns each FileStatus for the given fileEntry
array. Typically called with the result from dirReader.readEntries().
Parameters |
array of object |
fileEntries |
Properties of each object
|
function |
callback |
A callback type for getFileStatuses.
The callback parameter should be a function
that looks like this:
function(array of object status) {...};
array of object |
status |
Properties of each object
Entry |
fileEntry |
One of the Entry's originally given to getFileStatuses.
|
FileStatus |
status |
The status value can be 'synced' , 'pending' or 'conflicting' .
|
string |
(optional)
error |
Optional error that is only returned if there was a problem retrieving the FileStatus for the given file.
|
|
|
getServiceStatus
chrome.syncFileSystem.getServiceStatus(function callback)
Returns the current sync backend status.
Parameters |
function |
callback |
A callback type for getServiceStatus.
The callback parameter should be a function
that looks like this:
function( ServiceStatus status) {...};
|
Events
onServiceStatusChanged
Fired when an error or other status change has happened in the sync backend (for example, when the sync is temporarily disabled due to network or authentication error).
addListener
chrome.syncFileSystem.onServiceStatusChanged.addListener(function callback)
Parameters |
function |
callback |
The callback parameter should be a function
that looks like this:
function(object detail) {...};
|
|
onFileStatusChanged
Fired when a file has been updated by the background sync service.
addListener
chrome.syncFileSystem.onFileStatusChanged.addListener(function callback)
Parameters |
function |
callback |
The callback parameter should be a function
that looks like this:
function(object detail) {...};
object |
detail |
Entry |
fileEntry |
fileEntry for the target file whose status has changed. Contains name and path information of synchronized file. On file deletion, fileEntry information will still be available but file will no longer exist.
|
FileStatus |
status |
Resulting file status after onFileStatusChanged event. The status value can be 'synced' , 'pending' or 'conflicting' .
|
enum of "added" , "updated" , or "deleted" |
(optional)
action |
Sync action taken to fire onFileStatusChanged event. The action value can be 'added' , 'updated' or 'deleted' . Only applies if status is 'synced' .
|
enum of "local_to_remote" , or "remote_to_local" |
(optional)
direction |
Sync direction for the onFileStatusChanged event. Sync direction value can be 'local_to_remote' or 'remote_to_local' . Only applies if status is 'synced' .
|
|
|
|