5 releases (3 breaking)

0.4.0 Dec 20, 2022
0.3.0 Nov 24, 2022
0.2.1 Sep 9, 2022
0.2.0 Mar 25, 2022
0.1.0 Aug 27, 2019


Used in 2 crates

MIT license

57KB
973 lines

Latest Version Documentation License

High level synchronous AWS S3 Rust client library.

This client wraps Rusoto S3 and provides the following features:

  • check if bucket or object exists,
  • list objects that match prefix as iterator that handles pagination transparently,
  • put large objects via multipart API and follow upload progress via a callback,
  • delete single or multiple objects via bulk delete API,
  • deffer execution using ensure crate for putting and deleting objects.

Example usage

use s3_sync::{S3, Region, ObjectBodyMeta, BucketKey, Bucket};
use std::io::Cursor;
use std::io::Read;

let test_bucket = std::env::var("S3_TEST_BUCKET").expect("S3_TEST_BUCKET not set");
let test_key = "foobar.test";

let s3 = S3::default();

let bucket = s3.check_bucket_exists(Bucket::from_name(test_bucket)).expect("check if bucket exists")
    .left().expect("existing bucket");
let bucket_key = BucketKey::from_key(&bucket, test_key);

let body = Cursor::new(b"hello world".to_vec());
let object = s3.put_object(bucket_key, body, ObjectBodyMeta::default()).unwrap();

let mut body = Vec::new();
s3.get_body(&object).expect("object body").read_to_end(&mut body).unwrap();

assert_eq!(&body, b"hello world");

Dependencies

~19–27MB
~398K SLoC