Crate s3_sync

source ·
Expand description

High level synchronous S3 client.

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 progress via callback,
  • delete single or any number of 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");

Cargo features

  • chrono - enables parse method on LastModified

Re-exports

pub use ensure;
pub use either;

Structs

Represents S3 bucket.
Represents a pointer to an object in S3 bucket.
Represents an existing object and its metadata in S3.
Meta information about object body.
Wrapper of Rusoto S3 client that adds some high level imperative and declarative operations on S3 buckets and objects.
Information about transfer progress.

Enums

Method used for checking if given object exists
Represents last modified time and date.
An AWS region.
Possible errors in s3-sync library.
Information about status of the ongoing transfer.

Traits

Existing pair of bucket name and key strings.