extern crate s3;
use std::str;
use s3::bucket::Bucket;
use s3::credentials::Credentials;
use s3::error::S3Result;
const BUCKET: &str = "drazen-test-bucket-2";
const MESSAGE: &str = "I want to go to S3";
const REGION: &str = "us-east-1";
pub fn main() -> S3Result<()> {
let region = REGION.parse()?;
let credentials = Credentials::default();
let bucket = Bucket::new(BUCKET, region, credentials)?;
let (_, code) = bucket.put_object("test_file", MESSAGE.as_bytes(), "text/plain")?;
assert_eq!(200, code);
let (data, code) = bucket.get_object("test_file")?;
let string = str::from_utf8(&data).unwrap();
assert_eq!(200, code);
assert_eq!(MESSAGE, string);
println!("{:?}", bucket.location()?);
bucket.put_object_tagging("test_file", &[("test", "tag")])?;
println!("Tags set");
let (tags, _status) = bucket.get_object_tagging("test_file")?;
println!("{:?}", tags);
Ok(())
}