cloudflare-r2-rs

Crates.iocloudflare-r2-rs
lib.rscloudflare-r2-rs
version
sourcesrc
created_at2024-03-13 21:29:03.66053
updated_at2024-12-06 12:29:33.967708
descriptionA package which provides dead simple APIs to work with Cloudflare R2 and OVH Object Storage.
homepage
repositoryhttps://github.com/milen-denev/cloudflare-r2-rs
max_upload_size
id1172494
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Milen Denev (milen-denev)

documentation

README

Easy to use Rust API for Cloudflare's R2 service

Simple Rust API for Cloudflare's R2 and OVH Object Storage (possibly others as well but not tested) with create_bucket, delete_bucket and upload, get, delete file operations. Production ready since it's a thin layer above AWS SDK S3. Updated to be using latest versions.

cargo.toml

[dependencies]
cloudflare-r2-rs = "0.6.8"

example use


//Cloudflare
let r2_manager = R2Manager::new(
    //Bucket Name
    "my-bucket", 
    //Cloudflare URI endpoint
    "https://some-id-55353-53535.r2.cloudflarestorage.com",
    //API Token's Access Key ID
    "some-id-55353-53535",
    //API Token's Secret Access Key
    "some-long-secret-key-55353-53535-55353-53535"
).await;

//OVH
let _r2_manager2 = R2Manager::new_with_region(
    "bucket-name", 
    "https://s3.<region>.io.cloud.ovh.net",
    "some-id-55353-53535",
    "some-secret-55353-53535",
    "<region>").await;

//Gives control to set Cache-Control header and Content-Type header
r2_manager.upload("test", b"Hello world", Some("max-age=60"), Some("text/plain")).await;
let bytes = r2_manager.get("test").await.unwrap();
println!("{}", String::from_utf8(bytes).unwrap());
Commit count: 23

cargo fmt