Using Dropbox to save files: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
Replaced content with "'''''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.'''''"
Tag: Replaced
 
(32 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.'''''
 
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 [https://www.dropbox.com/developers/apps Dropbox App Console]. ==
 
=== 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 ==
 
=== 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. Put all the
<pre>
  s="This is my data"
  client.writeFile("MyData.txt", s, {}, writeComplete)
</pre>
* The file will be created in /DropBox/Apps/''yourAppName''
* You can use any extension.
* 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.
 
=== Read a file from your DropBox ===
 
=== Other Dropbox file commands ===
Full docs are [https://www.dropbox.com/developers/datastore/docs/js here].

Latest revision as of 14:15, 13 November 2020

Dropbox has a new API which is documented on their site. As a result, this page has been deprecated.