|
|
(19 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
| It's easy to save and read files on Dropbox using AppStudio, so you can access them on all your devices and on your desktop.
| | '''''Dropbox has a new API which is [https://www.dropbox.com/developers/documentation documented on their site]. As a result, this page has been deprecated.''''' |
| * Apps must be set up in Dropbox before they will run.
| |
| * Apps need to be deployed. They cannot run locally.
| |
| * You can only run someone else's app if you have their permission.
| |
| * Therefore you can only access someone else's files with their permission.
| |
| * If you want to access file on a record by record basis, use a [[Using a Dropbox Datastore|Dropbox Datastore]].
| |
| | |
| Here's how:
| |
| | |
| == Get a DropBox account. ==
| |
| | |
| Use your existing account or get a new one. They're free and easy to set up.
| |
| | |
| == Create your app in the Dropbox App Console ==
| |
| | |
| Go to [https://www.dropbox.com/developers/apps Dropbox App Console] and create a Dropbox API app, that does Files and data stores that it creates. It's also possible to access existing files in the Dropbox by choosing different options here.
| |
| | |
| [[File:Dropboxappconsole0.png|600px|none]]
| |
| | |
| | |
| === Settings ===
| |
| [[File:Dropboxappconsole1.png|600px|none]]
| |
| | |
| Settings Fields:
| |
| * Status: Development allows up to 100 users. To apply for Production, your app will have to approved by Dropbox.
| |
| * Developments users: Who is allowed to use the app?
| |
| * Permission type: Normally, read and write to its own folder.
| |
| * App Folder Name: Name the folder you want to use in Dropbox/Apps for your app's files. If it does not exist, it will be created.
| |
| * App key, App secret: Generated by Dropbox. Use App key in your app to identify the Dropbox app.
| |
| * OAuth redirect URIs: The complete URL to your deployed app, including index.html.
| |
| * Drop-ins domains: Not needed.
| |
| * Datastores: Not needed.
| |
| | |
| === Details ===
| |
| [[File:Dropboxappconsole2.png|500px|none]]
| |
| | |
| Details Fields:
| |
| * App name: The name of your app. Don't use "Dropbox" in the name.
| |
| * Publisher: Your name or the name of your company.
| |
| * Description: A description of your app.
| |
| * App website: The main website for your app.
| |
| * App icons: 64x64 and 256x256 images. You need to save them to your Dropbox before uploading them.
| |
| | |
| == Write your app ==
| |
| | |
| === Add the Dropbox library to your project ===
| |
| | |
| [[File:Dropboxlibrary.png|600px|none]]
| |
| | |
| === Log into Dropbox ===
| |
| | |
| Security is important to Dropbox apps. Before you can do anything, you need to login. Dropbox uses a security schema call [http://en.wikipedia.org/wiki/OAuth OAuth], which is fairly ease to use.
| |
| | |
| Here is what you do at the start of your app:
| |
| <pre>
| |
| Dim APP_KEY = "qx65sf9nruudj73"
| |
| Dim client = new Dropbox.Client({key: APP_KEY})
| |
| client.authenticate({interactive:False}, authenticationError)
| |
| | |
| Function authenticationError(err)
| |
| If err Then MsgBox "DropBox Authentication error: " & err
| |
| End Function
| |
| </pre>
| |
| | |
| Once this is done, you can check to see if the user is authorized. If not, you need to authenticate:
| |
| <pre>
| |
| client.authenticate()
| |
| </pre>
| |
| This will load the Dropbox web page, ask the user to log in if needed and get authorization for the app.
| |
| | |
| === Write a file to your DropBox ===
| |
| | |
| Once authenticated, writing files out is easy.
| |
| <pre>
| |
| s="This is my data"
| |
| client.writeFile("MyData.txt", s, {}, writeComplete)
| |
| | |
| Function writeComplete(err)
| |
| MsgBox "Data written. Error: " & err
| |
| End Function
| |
| </pre>
| |
| * The file will be created in /DropBox/Apps/''yourAppName''
| |
| * You can use any extension.
| |
| * It's your responsibility to format the data properly for the extension you use.
| |
| * If the file exists, it is overwritten by default.
| |
| * To prevent overwrite, put {noOverwrite: true} into the 3rd parameter.
| |
| * Data to be written out can be quite large.
| |
| * JSON is a nice format to use for structured data. Use [[JSON.Stringify|JSON.Stringify]] and [[JSON.Parse]].
| |
| * writeFile executes asynchronously.
| |
| * The last parameter is the function to call on completion of write.
| |
| * An error code is passed to the writeComplete function.
| |
| * If operation is successful, null is passed.
| |
| | |
| === Read a file from your DropBox ===
| |
| | |
| Reading is as easy as writing.
| |
| <pre>
| |
| client.readFile("MyData.txt", {}, readComplete)
| |
| | |
| Function readComplete(err, data)
| |
| MsgBox "Data read: " & data
| |
| End Function
| |
| </pre>
| |
| * The file will be read in /DropBox/Apps/yourAppName
| |
| * If the file exists, it is overwritten by default.
| |
| * JSON is a nice format to use for structured data. Use JSON.Stringify and JSON.Parse.
| |
| * readFile executes asynchronously.
| |
| * The last parameter is the function to call on completion of write.
| |
| * An error code and the data is passed to the readComplete function.
| |
| * If operation is successful, null is passed as err.
| |
| * There are additional options for data type, start position and number of bytes to read.
| |
| | |
| === Other Dropbox file commands ===
| |
| Here is the full list of calls that can be made to the Dropbox client. Docs are [https://www.dropbox.com/developers/datastore/docs/js here].
| |
| | |
| * signOut(options, callback)
| |
| * getAccountInfo(options, callback)
| |
| * readFile(path, options, callback)
| |
| * writeFile(path, data, options, callback)
| |
| * resumableUploadStep(data, cursor, callback)
| |
| * resumableUploadFinish(path, options, callback)
| |
| * stat(path, options, callback)
| |
| * readdir(path, options, callback)
| |
| * makeUrl(path, options, callback)
| |
| * history(path, options, callback)
| |
| * readThumbnail(path, options, callback)
| |
| * revertFile(path, versionTag, callback)
| |
| * findByName(path, namePattern, options, callback)
| |
| * makeCopyReference(path, callback)
| |
| * pullChanges(cursor, callback)
| |
| * mkdir(path, callback)
| |
| * remove(path, callback)
| |
| * copy(from, toPath, callback)
| |
| * move(fromPath, toPath, callback)
| |
| * appInfo(appKey, callback)
| |
| * isAppDeveloper(userId, appKey, callback)
| |
| * hasOauthRedirectUri(redirectUri, appKey, callback)
| |