WORK IN PROGRESS, NOT RECOMMENDED FOR PRODUCTION USE
Dropbox backend for RemoteStorage.js This file exposes a get/put/delete interface which is compatible with RemoteStorage.WireClient.
When remoteStorage.backend is set to ‘dropbox’, this backend will initialize and replace remoteStorage.remote with remoteStorage.dropbox.
In order to ensure compatibility with the public folder, <BaseClient.getItemURL> gets hijacked to return the Dropbox public share URL.
remoteStorage.setApiKeys('dropbox', { appKey: 'your-app-key' });
An app key can be obtained by registering your app at https://www.dropbox.com/developers/apps
Dropbox | WORK IN PROGRESS, NOT RECOMMENDED FOR PRODUCTION USE |
Functions | |
getDropboxPath(path) | Map a local path to a path in DropBox. |
LowerCaseCache | A cache which automatically converts all keys to lower case and can propagate changes up to parent folders. |
Functions | |
get | Get a value from the cache or defaultValue, if the key is not in the cache. |
propagateSet | Set a value and also update the parent folders with that value. |
propagateDelete | Delete a value and propagate the changes to the parent folders. |
justSet | Set a value without propagating. |
justDelete | Delete a value without propagating. |
RemoteStorage. | |
Functions | |
connect | Set the backed to ‘dropbox’ and start the authentication flow in order to obtain an API token from Dropbox. |
stopWaitingForToken | Stop waiting for the token and emit not-connected |
_getFolder | Get all items in a folder. |
get | Compatible with <RemoteStorage.WireClient.get> |
put | Compatible with RemoteStorage.WireClient |
delete | Compatible with <RemoteStorage.WireClient.delete> |
_shareIfNeeded | Calls share, if the provided path resides in a public folder. |
share | Gets a publicly-accessible URL for the path from Dropbox and stores it in _itemRefs. |
info | Fetches the user’s info from dropbox and returns a promise for it. |
_request | Make a HTTP request. |
fetchDelta | Fetches the revision of all the files from dropbox API and puts them into _revCache. |
_getMetadata | Gets metadata for a path (can point to either a file or a folder). |
_uploadSimple | Upload a simple file (the size is no more than 150MB). |
_deleteSimple | Deletes a file or a folder. |
A cache which automatically converts all keys to lower case and can propagate changes up to parent folders.
By default the set and delete methods are aliased to justSet and justDelete.
defaultValue | the value that is returned for all keys that don’t exist in the cache |
Functions | |
get | Get a value from the cache or defaultValue, if the key is not in the cache. |
propagateSet | Set a value and also update the parent folders with that value. |
propagateDelete | Delete a value and propagate the changes to the parent folders. |
justSet | Set a value without propagating. |
justDelete | Delete a value without propagating. |
Functions | |
connect | Set the backed to ‘dropbox’ and start the authentication flow in order to obtain an API token from Dropbox. |
stopWaitingForToken | Stop waiting for the token and emit not-connected |
_getFolder | Get all items in a folder. |
get | Compatible with <RemoteStorage.WireClient.get> |
put | Compatible with RemoteStorage.WireClient |
delete | Compatible with <RemoteStorage.WireClient.delete> |
_shareIfNeeded | Calls share, if the provided path resides in a public folder. |
share | Gets a publicly-accessible URL for the path from Dropbox and stores it in _itemRefs. |
info | Fetches the user’s info from dropbox and returns a promise for it. |
_request | Make a HTTP request. |
fetchDelta | Fetches the revision of all the files from dropbox API and puts them into _revCache. |
_getMetadata | Gets metadata for a path (can point to either a file or a folder). |
_uploadSimple | Upload a simple file (the size is no more than 150MB). |
_deleteSimple | Deletes a file or a folder. |
get: function ( path, options )
Compatible with <RemoteStorage.WireClient.get>
Checks for the path in _revCache and decides based on that if file has changed. Calls _getFolder is the path points to a folder.
Calls RemoteStorage.Dropbox.share afterwards to fill _itemRefs.
put: function ( path, body, contentType, options )
Compatible with RemoteStorage.WireClient
Checks for the path in _revCache and decides based on that if file has changed.
Calls RemoteStorage.Dropbox.share afterwards to fill _itemRefs.
'delete': function ( path, options )
Compatible with <RemoteStorage.WireClient.delete>
Checks for the path in _revCache and decides based on that if file has changed.
Calls RemoteStorage.Dropbox.share afterwards to fill _itemRefs.
_getMetadata: function ( path, options )
Gets metadata for a path (can point to either a file or a folder).
list | if path points to a folder, specifies whether to list the metadata of the folder’s children. False by default. |
path | the path to get metadata for |
options | see above |
A promise for the metadata
_uploadSimple: function ( params )
Upload a simple file (the size is no more than 150MB).
ifMatch | same as for get |
path | path of the file |
body | contents of the file to upload |
contentType | mime type of the file |
statusCode | HTTP status code |
revision | revision of the newly-created file, if any |
Map a local path to a path in DropBox.
var getDropboxPath = function ( path )
Get a value from the cache or defaultValue, if the key is not in the cache.
get : function ( key )
Set a value and also update the parent folders with that value.
propagateSet : function ( key, value )
Delete a value and propagate the changes to the parent folders.
propagateDelete : function ( key )
Set a value without propagating.
justSet : function ( key, value )
Delete a value without propagating.
justDelete : function ( key, value )
Set the backed to ‘dropbox’ and start the authentication flow in order to obtain an API token from Dropbox.
connect: function ()
Stop waiting for the token and emit not-connected
stopWaitingForToken: function ()
Get all items in a folder.
_getFolder: function ( path, options )
Compatible with RemoteStorage.WireClient.get
get: function ( path, options )
Compatible with RemoteStorage.WireClient
put: function ( path, body, contentType, options )
Compatible with RemoteStorage.WireClient.delete
'delete': function ( path, options )
Calls share, if the provided path resides in a public folder.
_shareIfNeeded: function ( path )
Gets a publicly-accessible URL for the path from Dropbox and stores it in _itemRefs.
share: function ( path )
Fetches the user’s info from dropbox and returns a promise for it.
info: function ()
Make a HTTP request.
_request: function ( method, url, options )
Fetches the revision of all the files from dropbox API and puts them into _revCache.
fetchDelta: function ()
Gets metadata for a path (can point to either a file or a folder).
_getMetadata: function ( path, options )
Upload a simple file (the size is no more than 150MB).
_uploadSimple: function ( params )
Deletes a file or a folder.
_deleteSimple: function ( path )