Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 79 lines (54 sloc) 2.655 kb
9fd1be1 Evan Meagher Started README content.
authored
1 # dropbox-node
2
3 An OAuth-enabled node.js client for working with the Dropbox API.
aaae1c7 Evan Meagher Added incomplete disclaimer to README.
authored
4
6232247 Evan Meagher Added installation and todo blurbs.
authored
5 ## Installation
6
ae5b4af Evan Meagher Wrote usage and testing sections.
authored
7 dropbox-node depends on [`node-oauth`](http://github.com/ciaranj/node-oauth).
6232247 Evan Meagher Added installation and todo blurbs.
authored
8
993b35f Evan Meagher Added instructions for installation via npm.
authored
9 To install via npm
10
11 npm install dropbox
12
13 To install by hand, download the module and create a symlink in `~/.node_libraries`
6232247 Evan Meagher Added installation and todo blurbs.
authored
14
15 $ ln -s /path/to/dropbox-node/ ~/.node_libraries/dropbox-node
16
ae5b4af Evan Meagher Wrote usage and testing sections.
authored
17 ## Usage
18
eac6a93 Evan Meagher Fix link to Dropbox developers site.
authored
19 To start, you'll need to grab a consumer key and secret from [dropbox.com/developers](https://dropbox.com/developers).
ae5b4af Evan Meagher Wrote usage and testing sections.
authored
20
21 ### OAuth credentials and object construction
22
23 First construct an OAuth client and acquire a valid access token and access token secret pair.
24
25 var sys = require('sys'),
26 DropboxClient = require('dropbox-node').DropboxClient,
27 OAuth = require('oauth').OAuth,
28 oauth = new OAuth('http://api.dropbox.com/0/oauth/request_token',
29 'http://api.dropbox.com/0/oauth/access_token',
30 consumer_key, consumer_secret,
c600640 Evan Meagher Update code examples in README.
authored
31 '1.0', null, 'HMAC-SHA1');
ae5b4af Evan Meagher Wrote usage and testing sections.
authored
32
33 Now create a DropboxClient object.
34
c600640 Evan Meagher Update code examples in README.
authored
35 var dropbox = new DropboxClient(oauth, access_token, access_token_secret);
ae5b4af Evan Meagher Wrote usage and testing sections.
authored
36
37 ### Calling API methods
38
39 `dropbox-node` provides methods covering [each of the Dropbox API methods](https://www.dropbox.com/developers/docs), excluding access token acquisition and account creation.
40
41 For example, to fetch and print the display name and email address associated with your account:
42
43 dropbox.getAccountInfo(function(err, data) {
c600640 Evan Meagher Update code examples in README.
authored
44 if (err) console.log('Error: ' + sys.inspect(err));
ae5b4af Evan Meagher Wrote usage and testing sections.
authored
45 else {
c600640 Evan Meagher Update code examples in README.
authored
46 console.log(data.display_name + ', ' + data.email);
ae5b4af Evan Meagher Wrote usage and testing sections.
authored
47 }
c600640 Evan Meagher Update code examples in README.
authored
48 });
ae5b4af Evan Meagher Wrote usage and testing sections.
authored
49
50 Here's an example where we upload a file and remotely move it around before deleting it.
51
52 // Upload foo.txt to the Dropbox root directory.
53 dropbox.putFile('foo.txt', '', function(err, data) {
5e24ff7 Evan Meagher Fix broken control flow of example in README.
authored
54 if (err) console.error(err.stack);
55 else {
56 // Move it into the Public directory.
57 dropbox.move('foo.txt', 'Public/foo.txt', function(err, data) {
58 if (err) console.error(err.stack);
59 else {
60 // Delete the file.
61 dropbox.deleteItem('Public/foo.txt', function(err, data) {
62 if (err) console.error(err.stack);
63 });
64 }
65 });
66 }
c600640 Evan Meagher Update code examples in README.
authored
67 });
ae5b4af Evan Meagher Wrote usage and testing sections.
authored
68
69 ## Testing
70
71 `dropbox-node` depends on [`jasmine-node`](http://github.com/mhevery/jasmine-node) for testing. Note that the currently-implemented tests are trivial at best.
72
73 Run specs with `node specs.js` from the root `dropbox-node` directory.
74
6232247 Evan Meagher Added installation and todo blurbs.
authored
75 ## TODO
76 * Improve test coverage.
a8ad6eb Evan Meagher Add documentation todo item.
authored
77 * Improve documentation.
ae5b4af Evan Meagher Wrote usage and testing sections.
authored
78 * Add ability to interact with application sandboxes.
Something went wrong with that request. Please try again.