Skip to main content

Crate rusty_s3

Crate rusty_s3 

Source
Expand description

A simple, pure Rust AWS S3 client following a Sans-IO approach

The rusty-s3 crate provides a convenient API for signing, building and parsing AWS S3 requests and responses. It follows a Sans-IO approach, meaning that the library itself doesn’t send any of the requests. It’s the responsibility of the user to choose an HTTP client, be it synchronous or asynchronous, and use it to send the requests.

§Basic getting started example

use std::env;
use std::time::Duration;
use rusty_s3::{Bucket, Credentials, S3Action, UrlStyle};

// setting up a bucket
let endpoint = "https://s3.dualstack.eu-west-1.amazonaws.com".parse().expect("endpoint is a valid Url");
let path_style = UrlStyle::VirtualHost;
let name = "rusty-s3";
let region = "eu-west-1";
let bucket = Bucket::new(endpoint, path_style, name, region).expect("Url has a valid scheme and host");

// setting up the credentials
let key = env::var("AWS_ACCESS_KEY_ID").expect("AWS_ACCESS_KEY_ID is set and a valid String");
let secret = env::var("AWS_SECRET_ACCESS_KEY").expect("AWS_SECRET_ACCESS_KEY is set and a valid String");
let credentials = Credentials::new(key, secret);

// signing a request
let presigned_url_duration = Duration::from_secs(60 * 60);
let action = bucket.get_object(Some(&credentials), "duck.jpg");
println!("GET {}", action.sign(presigned_url_duration));

§Features

  • rustcrypto (enabled by default), aws-lc-rs and graviola: the cryptography used for signing requests. At least one of them must be enabled. If more are, aws-lc-rs is preferred over rustcrypto, which is preferred over graviola, so to avoid building rustcrypto with another one, disable the default features and enable full again, like with default-features = false, features = ["aws-lc-rs", "full"].
  • xml: the actions which send or receive XML, like ListObjectsV2 and the ones for multipart uploads.
  • full (enabled by default): xml, plus DeleteObjects, GetBucketPolicy and the parsing of the credentials returned by the EC2 metadata service.
  • wasm_bindgen: get the current time from JavaScript, which is needed to sign requests on wasm32-unknown-unknown.

Re-exports§

pub use self::actions::S3Action;
pub use self::credentials::Credentials;

Modules§

actions
S3 request building and response parsing support
credentials
Credentials management types
signing
Signing of requests with AWS Signature Version 4

Structs§

Bucket
An S3 bucket
Map
A map used for holding query string parameters or headers

Enums§

BucketError
An error creating a Bucket
Method
The HTTP request method for an S3Action.
UrlStyle
The request url format of a S3 bucket.