Crates.io | backblaze-b2-client |
lib.rs | backblaze-b2-client |
version | 0.1.5 |
created_at | 2025-03-17 13:22:11.796977+00 |
updated_at | 2025-04-11 11:49:28.936471+00 |
description | Backblaze B2 Client for Rust |
homepage | |
repository | https://github.com/SalahaldinBilal/backblaze-b2-client-rs |
max_upload_size | |
id | 1595466 |
size | 240,659 |
This is a Rust client library for the Backblaze B2 cloud storage service. It provides a convenient interface for interacting with the B2 API. Relies on Tokio async runtime.
The crate provides a simple client B2SimpleClient
that is just a mapping with b2 requests, and a normal client B2Client
that provides helpful utilities
and auto re-auth to make life easier, you can access its inner basic client, currently only file uploads with create_upload
.
The crate is still a work in progress, so expect breaking changes between 0.0.X versions.
Add the following dependency to your project using the cargo add
command:
cargo add backblaze-b2-client
use backblaze_b2_client::B2Client;
use tokio::fs::File;
#[tokio::main]
fn main() {
let client = B2Client::new("your_account_id", "your_application_key");
let file = File::open("path_to_file").await.unwrap();
let metadata = open_file.metadata().await.unwrap();
let upload = client.create_upload(
file,
"file_name".into(),
"bucket_id".into(),
None,
metadata.len(),
None,
).await;
let file_handle_copy = file_handle.clone();
tokio::spawn(async move {
let file_handle = file_handle_copy.clone();
// Logs progress to console every half a second
while !file_handle.has_stopped() {
println!(
"status: {:?}, stats: {:.2}",
file_handle.status(),
file_handle.stats().current_stats()
);
sleep(Duration::from_millis(500)).await;
}
});
// Starts the file upload and waits for it to finish
let file = upload.start().await.unwrap();
println!("{:#?}", file);
}
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or suggestions, please open an issue on GitHub.