#对象存储 #Cloudflare #S3 #r2 #存储服务 #云存储 #API令牌

cloudflare-r2-rs

一个提供与 Cloudflare R2 和 OVH 对象存储协同工作的简单 API 的包

8 个版本 (5 个破坏性更新)

0.6.2 2024 年 7 月 7 日
0.6.1 2024 年 7 月 3 日
0.6.0 2024 年 6 月 18 日
0.5.0 2024 年 6 月 17 日
0.1.0 2024 年 3 月 13 日

#708 in 网页编程

Download history 307/week @ 2024-05-25 40/week @ 2024-06-01 143/week @ 2024-06-08 349/week @ 2024-06-15 28/week @ 2024-06-22 155/week @ 2024-06-29 146/week @ 2024-07-06 42/week @ 2024-07-13 143/week @ 2024-07-20 128/week @ 2024-07-27

每月 506 次下载

Apache-2.0

15KB
183

易于使用的 Cloudflare R2 服务的 Rust API

简单的 Rust API,用于 Cloudflare 的 R2 和 OVH 对象存储(可能还有其他服务,但未测试),包括 创建存储桶删除存储桶上传获取删除 文件操作。由于它是 AWS SDK S3 之上的薄层,因此已准备好用于生产。已更新到最新版本。

cargo.toml

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

示例使用


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

依赖项

~27MB
~423K SLoC