Dbox
NodeJS SDK for Dropbox API (THIS LIBRARY IS OBSOLETE!!)
Install / Use
/learn @sintaxi/DboxREADME
dbox (THIS LIBRARY IS V1 ONLY WHICH IS NOW OBSOLETE!!)
A Node.JS convenience wrapper around the Dropbox API. Simplifies OAuth handshake and removes HTTP ceremony.
Installation
I always recommend you bundle your dependencies with your application. To do
this, create a package.json file in the root of your project with the minimum
information...
{
"name": "yourapplication",
"version": "0.1.0",
"dependencies": {
"dbox": "0.6.1"
}
}
Then run the following command using npm...
npm install
OR, if you just want to start playing with the library run...
npm install dbox
API Overview
dbox methods (where dbox is set from requiring the dbox library)...
app <-- creates application object
app methods (where app is created from the above app call)...
requesttoken <-- creates request token for getting request token and authorization url
accesstoken <-- creates access token for creating a client object
client <-- creates client object with access to users dropbox account
client methods (where client is created from the above client call)...
account <-- view account
mkdir <-- make directory
mv <-- move file or directory
cp <-- copy file or directory
rm <-- remove file or directory
put <-- upload file
get <-- download file
metadata <-- get file or directory information
revisions <-- get revision history
restore <-- restore previous version
search <-- search directory
shares <-- create link to view file
media <-- create streamable link to file
thumbnails <-- get thumbnail of file
copyref <-- create copy reference to file
delta <-- get list of delta entries
stream <-- creates readable stream
readdir <-- recursively reads directory
How to Use
Creating a functional dbox client is a four step process.
- create an
appusing application credentials provided by dropbox - obtain request token to use for generation access token
- have user visit authorization URL to grant access to your application
- create a client using access token that was generated earlier
Step 1
var dbox = require("dbox")
var app = dbox.app({ "app_key": "umdez34678ck01fx", "app_secret": "tjm89017sci88o6" })
Step 2
Authorization is a three step process.
a) Get a request token...
app.requesttoken(function(status, request_token){
console.log(request_token)
})
b) User must visit the url to grant authorization to the client...
https://www.dropbox.com/1/oauth/authorize?oauth_token=#{ request_token.oauth_token }
c) Generate our access token with the request token...
app.accesstoken(request_token, function(status, access_token){
console.log(access_token)
})
Step 3
var client = app.client(access_token)
Now we have a client that gives us access to all the api functionality.
Client Methods
account([options,] callback)
Returns account information.
client.account(function(status, reply){
console.log(reply)
})
output of reply returns...
{
uid: 123456789,
display_name: 'Brock Whitten',
email: 'brock@sintaxi.com',
country: 'CA',
referral_link: 'https://www.dropbox.com/referrals/NTc0NzYwNDc5',
quota_info: {
shared: 1100727791,
quota: 2415919104,
normal: 226168599
}
}
mkdir(path, [options,] callback)
Creates directory at specified location.
client.mkdir("foo", options, function(status, reply){
console.log(reply)
})
output of reply returns...
{
"size": "0 bytes",
"rev": "1f477dd351f",
"thumb_exists": false,
"bytes": 0,
"modified": "Wed, 10 Aug 2011 18:21:30 +0000",
"path": "/foo",
"is_dir": true,
"icon": "folder",
"root": "sandbox",
"revision": 5023410
}
mv(from_path, to_path, [options,] callback)
Moves file or directory to a new location.
client.mv("foo", "bar", function(status, reply){
console.log(reply)
})
output of reply returns...
{
"size": "0 bytes",
"rev": "irt77dd3728",
"thumb_exists": false,
"bytes": 0,
"modified": "Wed, 10 Aug 2011 18:21:30 +0000",
"path": "/bar",
"is_dir": true,
"icon": "folder",
"root": "sandbox",
"revision": 5023410
}
cp(from_path, to_path, [options,] callback)
Copies a file or directory to a new location.
client.cp("bar", "baz", function(status, reply){
console.log(reply)
})
{
"size": "0 bytes",
"rev": "irt77dd3728",
"thumb_exists": false,
"bytes": 0,
"modified": "Wed, 10 Aug 2011 18:21:30 +0000",
"path": "/baz",
"is_dir": true,
"icon": "folder",
"root": "sandbox",
"revision": 5023410
}
rm(path, [options,] callback)
Removes a file or directory.
client.rm("README.txt", function(status, reply){
console.log(reply)
})
output of reply returns...
{
"size": "0 bytes",
"is_deleted": true,
"bytes": 0,
"thumb_exists": false,
"rev": "1f33043551f",
"modified": "Wed, 10 Aug 2011 18:21:30 +0000",
"path": "/README.txt",
"is_dir": false,
"icon": "page_white_text",
"root": "sandbox",
"mime_type": "text/plain",
"revision": 492341
}
put(path, data, [options,] callback)
Creates or modifies a file with given data. data may be a string or a buffer.
client.put("foo/hello.txt", "here is some text", function(status, reply){
console.log(reply)
})
output of reply returns...
{
"size": "225.4KB",
"rev": "35e97029684fe",
"thumb_exists": false,
"bytes": 230783,
"modified": "Tue, 19 Jul 2011 21:55:38 +0000",
"path": "/foo/hello.txt",
"is_dir": false,
"icon": "page_white_text",
"root": "sandbox",
"mime_type": "text/plain",
"revision": 220823
}
get(path, [options,] callback)
Pulls down file (available as a buffer) with its metadata.
client.get("foo/hello.txt", function(status, reply, metadata){
console.log(reply.toString(), metadata)
})
output of reply.toString() returns...
here is some text
output of metadata returns...
{
"revision": 11,
"rev": "b07a93bb3",
"thumb_exists": false,
"bytes": 17,
"modified": "Sat, 12 May 2012 19:31:08 +0000",
"client_mtime": "Sat, 12 May 2012 19:30:52 +0000",
"path": "/foo/hello.txt",
"is_dir": false,
"icon": "page_white_text",
"root": "app_folder",
"mime_type": "text/plain",
"size": "17 bytes"
}
metadata(path, [options,] callback)
Retrieves file or directory metadata.
// available options...
var options = {
file_limit : 10000, // optional
hash : ..., // optional
list : true, // optional
include_deleted : false, // optional
rev : 7, // optional
locale: : "en", // optional
root: : "sandbox" // optional
}
client.metadata("Getting_Started.pdf", options, function(status, reply){
console.log(reply)
})
output of reply returns...
{
"size": "225.4KB",
"rev": "35e97029684fe",
"thumb_exists": false,
"bytes": 230783,
"modified": "Tue, 19 Jul 2011 21:55:38 +0000",
"path": "/Getting_Started.pdf",
"is_dir": false,
"icon": "page_white_acrobat",
"root": "sandbox",
"mime_type": "application/pdf",
"revision": 220823
}
revisions(path, [options,] callback)
Obtains metadata for the previous revisions of a file.
// available options...
var options = {
rev_limit : 10, // optional
locale: : "en" // optional
}
client.revisions("foo/hello.txt", options, function(status, reply){
console.log(reply)
})
output of reply returns...
[
{
"is_deleted": true,
"revision": 4,
"rev": "40000000d",
"thumb_exists": false,
"bytes": 0,
"modified": "Wed, 20 Jul 2011 22:41:09 +0000",
"path": "foo/hello.txt",
"is_dir": false,
"icon": "page_white",
"root": "sandbox",
"mime_type": "text/plain",
"size": "0 bytes"
},
{
"revision": 1,
"rev": "10000000d",
"thumb_exists": false,
"bytes": 3,
"modified": "Wed, 20 Jul 2011 22:40:43 +0000",
"path": "foo/hello.txt",
"is_dir": false,
"icon": "page_white",
"root": "sandbox",
"mime_type": "text/plain",
"size": "3 bytes"
}
]
restore(path, rev, [options,] callback)
Restores a file path to a previous revision.
client.revisions("foo/hello.txt", 4, function(status, reply){
console.log(reply)
})
output of reply returns...
{
"is_deleted": true,
"revision": 4,
"rev": "40000000d",
"thumb_exists": false,
"bytes": 0,
"modified": "Wed, 20 Jul 2011 22:41:09 +0000",
"path": "/foo/hello.txt",
"is_dir": false,
"icon": "page_white",
"root": "sandbox",
"mime_type": "text/plain",
"size": "0 bytes"
}
search(path, query, [options,] callback)
Returns metadata for all files and directories that match the search query.
var options = {
file_limit : 10000,
Related Skills
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
