#cloudflare #object-storage #r2 #api-token #access-key #key-id #secret-key

cloudflare-r2-rs

A package which provides dead simple APIs to work with Cloudflare R2

4 releases (breaking)

new 0.4.0 Jun 11, 2024
0.3.0 May 28, 2024
0.2.0 May 27, 2024
0.1.0 Mar 13, 2024

#615 in Network programming

Download history 93/week @ 2024-03-12 6/week @ 2024-03-19 1/week @ 2024-03-26 15/week @ 2024-04-02 65/week @ 2024-05-21 260/week @ 2024-05-28

325 downloads per month

Apache-2.0

15KB
143 lines

Easy to use Rust API for Cloudflare's R2 service

Simple Rust API for Cloudflare's R2 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.4.0"

example use

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;

//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());

Dependencies

~28MB
~426K SLoC