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§

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

Enums§

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

Traits§

Captures1
Captures2
PresentBucketKeyName
Existing pair of bucket name and key strings.