10 releases (5 breaking)

0.7.0 Feb 27, 2024
0.7.0-dev.0 Feb 23, 2024
0.6.0 Nov 6, 2023
0.5.0 Oct 12, 2023
0.1.2 Aug 30, 2022

#4 in #phat-contract

Download history 11/week @ 2024-09-23

219 downloads per month

Apache-2.0

85KB
1K SLoC

pink-s3

Simple pure Rust AWS S3 Client for Phala network's pink environment.

Examples

# fn doctest_ignore() {

use pink_s3 as s3;

let endpoint = "s3.ap-southeast-1.amazonaws.com";
let region = "ap-southeast-1";
let access_key = "<Put your S3 access key here>";
let secret_key = "<Put your S3 access secret key here>";

let s3 = s3::S3::new(endpoint, region, access_key, secret_key)
    .unwrap()
    .virtual_host_mode(); // virtual host mode is required for newly created AWS S3 buckets.

let bucket = "my-wallet";
let object_key = "path/to/foo";
let value = b"bar";

s3.put(bucket, object_key, value).unwrap();

let head = s3.head(bucket, object_key).unwrap();
let mut head_content_length: u64 = 0;
for (k, v) in head.headers {
    if k.to_ascii_lowercase() == "content-length" {
        head_content_length = v.parse().expect("expect length")
    }
}
assert_eq!(head_content_length, value.len() as u64);

let v = s3.get(bucket, object_key).unwrap().body;
assert_eq!(v, value);

s3.delete(bucket, object_key).unwrap();

# }

Supported S3 actions

  • HeadObject
  • GetObject
  • PutObject
  • DeleteObject

Dependencies

~9–13MB
~229K SLoC