Crates.io | rusty_dropbox_sdk |
lib.rs | rusty_dropbox_sdk |
version | 0.1.1 |
source | src |
created_at | 2024-10-02 13:22:28.793555 |
updated_at | 2024-10-03 09:51:28.425234 |
description | Unofficial SDK for dropbox in Rust |
homepage | |
repository | https://github.com/leichak/rusty-dropbox-api |
max_upload_size | |
id | 1394037 |
size | 228,556 |
Unofficial Dropbox API SDK for Rust
This crate provides a simple and idiomatic Rust interface to interact with the Dropbox API. It supports common Dropbox operations such as file uploads, downloads, and handling OAuth2 tokens. This SDK is asynchronous and integrates well with Rust's async ecosystem, utilizing tokio
.
The following Dropbox API categories have support in the SDK:
account
auth
check
contacts
file_properties
file_requests
Planned:
files
, sharing
, users
Full support for all Dropbox API endpoints is coming soon!
Add the following to your Cargo.toml
:
[dependencies]
rusty_dropbox_sdk = "0.1"
tokio = { version = "1", features = ["full"] }
Here's a basic example showing how to revoke an OAuth2 token.
use dropbox_api::api;
use dropbox_api::api::Service;
fn main() {
let request = api::auth::token_revoke::TokenRevokeRequest {
access_token: "your_access_token",
payload: None,
};
match Service::call_sync(&request) {
Ok(Some(result)) => println!("Token revoked: {:?}", result),
_ => println!("Failed to revoke token or connection not present"),
}
}
use dropbox_api::api;
use tokio;
#[tokio::main]
async fn main() {
let request = api::auth::token_revoke::TokenRevokeRequest {
access_token: "your_access_token",
payload: None,
};
match request.call().await {
Ok(result) => println!("Token revoked: {:?}", result),
Err(e) => println!("Error: {:?}", e),
}
}
Here’s an advanced example of creating a file request using Dropbox API:
use dropbox_api::api::file_requests::{CreateFileRequestArgs, FileRequestDeadline};
use dropbox_api::api::Service;
use chrono::DateTime;
#[tokio::main]
async fn main() {
let request = api::file_requests::create::CreateFileRequest {
access_token: "your_access_token",
payload: Some(CreateFileRequestArgs {
title: "File Request".to_string(),
destination: "/path/to/destination".to_string(),
deadline: Some(FileRequestDeadline {
deadline: DateTime::from_timestamp_millis(1690000000000).unwrap(),
allow_late_uploads: None,
}),
open: false,
description: Some("A request for a file.".to_string()),
video_project_id: None,
}),
};
match request.call().await {
Ok(result) => println!("File request created: {:?}", result),
Err(e) => println!("Error: {:?}", e),
}
}
To run integration tests, use the following command:
cargo test --test '*'
To run local tests, use following commands:
cargo test --features "test-utils"
This is an unofficial release of the Dropbox API SDK for Rust. Contributions and issues are welcome. Please follow the standard GitHub flow for contributions.
This project is licensed under the GNU General Public License v3.0