Dropbox
Dropbox services support.
Capabilities
This service can be used to:
- stat
- read
- write
- create_dir
- delete
- copy
- rename
- list
- batch
- blocking
Configuration
root
: Set the work directory for this backend.
Credentials related
Just provide Access Token (Temporary)
access_token
: set the access_token for this backend. Please notice its expiration.
Or provide Client ID and Client Secret and refresh token (Long Term)
If you want to let OpenDAL to refresh the access token automatically, please provide the following fields:
refresh_token
: set the refresh_token for dropbox apiclient_id
: set the client_id for dropbox apiclient_secret
: set the client_secret for dropbox api
OpenDAL is a library, it cannot do the first step of OAuth2 for you. You need to get authorization code from user by calling Dropbox's authorize url and exchange it for refresh token.
Please refer to Dropbox OAuth2 Guide for more information.
You can refer to [DropboxBuilder
]'s docs for more information
Example
Via Builder
use anyhow::Result;
use opendal::raw::OpWrite;
use opendal::services::Dropbox;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
let mut builder = Dropbox::default();
builder.root("/opendal");
builder.access_token("<token>");
let op: Operator = Operator::new(builder)?.finish();
Ok(())
}
Via Config
- Rust
- Node.js
- Python
use anyhow::Result;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<()> {
let mut map = HashMap::new();
map.insert("root".to_string(), "/path/to/dir".to_string());
map.insert("access_token".to_string(), "your_access_token".to_string());
let op: Operator = Operator::via_map(Scheme::Dropbox, map)?;
Ok(())
}
import { Operator } from "opendal";
async function main() {
const op = new Operator("dropbox", {
root: "/path/to/dir",
access_token: "your_access_token",
});
}
import opendal
op = opendal.Operator("dropbox",
root="/path/to/dir",
access_token="your_access_token",
)