s3-presign

Crates.ios3-presign
lib.rss3-presign
version
sourcesrc
created_at2023-01-15 07:34:28.015964
updated_at2024-10-18 04:21:21.183134
descriptionA minimal library for generating presigned URLs for Amazon S3 compatible services
homepagehttps://github.com/andelf/s3-presign
repositoryhttps://github.com/andelf/s3-presign
max_upload_size
id759285
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
Andelf (andelf)

documentation

https://docs.rs/s3-presign

README

s3-presign

Minimal library to get an S3 presign URL.

Usage

use s3_presign::{Credentials, Presigner};

let credentials = Credentials::new(
    "blah.....blah...",
    "blah.....xxxxxxx",
    None,
);

let bucket = "my-bucket";
let region = "us-east-1";

let mut presigner = Presigner::new(credentials, bucket, region);
// presigner.endpoint(endpoint);
let url = self.presigner.url_for_s3_url(path).unwrap();

let signed_url = self.sign_s3_request("HEAD", &url);

let signed_url = self.sign_s3_request("PUT", &url);
let signed_url = self.sign_s3_request("GET", &url);

S3-compatible APIs

If you want to use the presigner with a different service that exposes an S3-compatible API (like Cloudflare R2), you can do so by specifying a root when creating the Presigner/Bucket.

let root = "xxxxx.eu.r2.cloudflarestorage.com";

let bucketObj = Bucket::mew_with_root(bucket, root, root);
let mut preBucket = Presigner::from_bucket(credentials, bucketObj);
preBucket.use_path_style(); // Cloudflare R2 only works with Path-Style!!!

let mut presigner = Presigner::new_with_root(credentials, bucket, region, root);

⚠️ Cloudflare R2

The R2s S3-API requires path style! Therefore, you can not use the global convenience function. Instead you need to create a Presigner and call Presigner::use_path_style(&self) on it.

Commit count: 13

cargo fmt