Expand description

Simple AWS S3

Provides the simple way to work with AWS S3. It use reqwest to execute the reqwest.

This package is developing while waiting the fully supported from aws-sdk from Amazon.


  • Post Presigned (Upload from browser)
  • Get Presigned (Download from browser)
  • Bucket Operations:
  • Object Operations:
    • Head Object (Retrieve Information of an Object)
    • Delete Object


use chrono::Duration; use reqwest::multipart::{Form, Part}; use reqwest::StatusCode; use simple_aws_s3::{PostPresignedInfo, S3};

// Before run this example, please replace s3 config below by your config. const ACCESS_KEY: &str = “AKIAIOSFODNN7EXAMPLE”; const SECRET_KEY: &str = “wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY”; const REGION: &str = “us-east-1”; const ENDPOINT: &str = “s3.amazonaws.com”; const BUCKET: &str = “examplebucket”;

#[tokio::main] async fn main() { let s3 = S3::new(BUCKET, REGION, ENDPOINT, ACCESS_KEY, SECRET_KEY);

let key = String::from("text.txt");
let content = "Hello world";

// Upload by Post Presigned
let PostPresignedInfo { upload_url, params } = s3
let mut form = Form::new();
for (key, value) in params {
    form = form.text(key, value);
let part = Part::text(content).mime_str("plain/text").unwrap();
form = form.part("file", part);
let res = reqwest::Client::new()
assert_eq!(res.status(), StatusCode::NO_CONTENT);

// Download by Query Param (Get Presigned)
let download_url = s3.generate_presigned_get(&key, 3600).unwrap();
let res = reqwest::Client::new()
assert_eq!(res.status(), StatusCode::OK);
assert_eq!(res.text().await.unwrap(), content);



pub use s3::*;
pub use s3_constant::*;
pub use s3_post_policy::*;
pub use s3_signer::*;
pub use s3_string_to_sign::*;