Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andelf/s3-presign
A minimal library for generating presigned URLs for Amazon S3 compatible services
https://github.com/andelf/s3-presign
Last synced: about 1 month ago
JSON representation
A minimal library for generating presigned URLs for Amazon S3 compatible services
- Host: GitHub
- URL: https://github.com/andelf/s3-presign
- Owner: andelf
- License: apache-2.0
- Created: 2024-03-13T07:14:24.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2024-10-18T04:21:50.000Z (about 1 month ago)
- Last Synced: 2024-10-18T07:15:03.170Z (about 1 month ago)
- Language: Rust
- Size: 23.4 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# s3-presign
Minimal library to get an S3 presign URL.
## Usage
```rust
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`.```rust
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.