Newer: Dropbox Datastore API & dropbox.js wrapper for Amber Smalltalk.
Currently, new version is not documented yet. No sample codes. But Dropbox-Datastore.st is a package for the Datastore API support.
Legacy: dropbox.js wrapper for Amber Smalltalk
Just copy and merge the whole directory to your Amber Smalltalk home. Use copyAll.sh or copyAll.bat, according to your platform.
| dropboxCli |
dropboxCli := DrClient default.
dropboxCli authenticateThen: [
dropboxCli writeFile: 'hello.txt' data: 'world'.
].
By default, DrClient create 'Amber_ToDo_Demo' app folder to your dropbox (for the convenience of the example below). You can change the app folder by obtaining your own API key from dropbox.
API key can be set by DrClient defaultApiKey: 'encoded api key'
. The method only accepts encoded API key for security reasons. Encoding can be done by Dropbox API key encoder.
DrClient's default authentication driver is Redirect. It is suitable in most cases.
However, in mobile devises, Cordova driver would be better.
You can explicitly set the driver by DrClient defaultAuthDriverType:'redirect|popup|chrome|cordova|nodeserver'
. Please read dropbox.js authentication drivers document for the differences.
drop-todo.html is the example of setting API key and auth driver from JavaScript side.
smalltalk.DrClient._defaultApiKey_('lT8r2O3iMCA=|ULla/D4WPtfkec3nxbtR+V861w9E+U9+krMlTYrV/A==');
smalltalk.DrClient._defaultAuthDriverType_('cordova');
dropboxFromAmber includes an extended ToDoList example. While the original jqmFromAmber example stores data to html5 localStorage, this version saves tasks to Dropbox.
How to try the example:
- install the demo prerequisite -- jqmFromAmber. It is used for ToDoList UI.
- start amber server
- open the demo page (http://localhost:4000/dropboxFromAmber.html) with your favorite web browser.
See the 'Dropbox-ToDo' package for details.