Crates.io | s3-sync |
lib.rs | s3-sync |
version | 0.4.0 |
source | src |
created_at | 2019-08-27 15:26:28.830361 |
updated_at | 2022-12-20 15:38:32.941611 |
description | High level synchronous AWS S3 client |
homepage | https://sr.ht/~jpastuszek/s3-sync/ |
repository | https://git.sr.ht/~jpastuszek/s3-sync |
max_upload_size | |
id | 160082 |
size | 57,532 |
High level synchronous AWS S3 Rust client library.
This client wraps Rusoto S3 and provides the following features:
ensure
crate for putting and deleting objects.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");