Rust library for working with Amazon S3
Increasingly more loosly based on crates.io implementation.
Very modest interface towards Amazon S3.
Supports put
, get
and list
, with delete
on the roadmap and will be done eventually,
probably around the time I discover I need it in some other project :).
The main (and probably only) cool feature is that put
commands return a presigned link to the file you uploaded.
This means you can upload to s3, and give the link to select people without having to worry about publicly accessible files on S3.
Compile time configuration is done using Config.toml,
curtosy of confy. You don't really have to touch anything there, maybe amz-expire
,
it is configured for one week which is the maximum Amazon allows ATM.
``` extern crate s3 use s3::{Bucket, puts3, gets3, list_s3};
const S3BUCKET: &'static str = "bucketname"; const AWSACCESS: &'static str = "accesskey"; const AWSSECRET: &'static str = "secretkey";
fn main () { // Bucket instance let bucket = Bucket::new(S3BUCKET.tostring(), None, AWSACCESS.tostring(), AWSSECRET.tostring(), &"https");
// Put let putme = "I want to go to S3".tostring(); let url = puts3(&bucket, &"/", &putme.as_bytes()); println!("{}", url);
// List let bytes = lists3(&bucket, &"/", &"/", &"/"); let string = String::fromutf8_lossy(&bytes); println!("{}", string);
// Get let path = &"testfile"; let mut buffer = match File::create(path) { Ok(x) => x, Err(e) => panic!("{:?}, {}", e, path) }; let bytes = gets3(&bucket, Some(&path)); match buffer.write(&bytes) { Ok(_) => {} // info!("Written {} bytes from {}", x, path), Err(e) => panic!("{:?}", e) } } ```