Struct s3::Bucket [] [src]

pub struct Bucket { /* fields omitted */ }

Object holding info about an S3 bucket which provides easy access to S3 operations.

Example

use s3::{Bucket, Credentials};

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::new("access_key", "secret_key", None);

let bucket = Bucket::new(bucket_name, region, credentials);

Methods

impl Bucket
[src]

Instantiate a new Bucket.

Example

use s3::{Bucket, Credentials};

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::new("access_key", "secret_key", None);

let bucket = Bucket::new(bucket_name, region, credentials);

Gets file from an S3 path.

Example:

use s3::{Bucket, Credentials};

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::new("access_key", "secret_key", None);
let bucket = Bucket::new(bucket_name, region, credentials);

let (data, code) = bucket.get("/test.file").unwrap();
println!("Code: {}\nData: {:?}", code, data);

Delete file from an S3 path.

Example:

use s3::{Bucket, Credentials};

let bucket_name = &"rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::new("access_key", "secret_key", None);
let bucket = Bucket::new(bucket_name, region, credentials);

let (_, code) = bucket.delete("/test.file").unwrap();
assert_eq!(204, code);

Put into an S3 bucket.

Example

use s3::{Bucket, Credentials};

let bucket_name = &"rust-s3-test";
let aws_access = &"access_key";
let aws_secret = &"secret_key";

let bucket_name = &"rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::new("access_key", "secret_key", None);
let bucket = Bucket::new(bucket_name, region, credentials);

let content = "I want to go to S3".as_bytes();
let (_, code) = bucket.put("/test.file", content, "text/plain").unwrap();
assert_eq!(201, code);

List the contents of an S3 bucket.

Example

use std::str;
use s3::{Bucket, Credentials};
let bucket_name = &"rust-s3-test";
let aws_access = &"access_key";
let aws_secret = &"secret_key";

let bucket_name = &"rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::new("access_key", "secret_key", None);
let bucket = Bucket::new(bucket_name, region, credentials);

let (list, code) = bucket.list("/", Some("/")).unwrap();
assert_eq!(200, code);
let string = str::from_utf8(&list).unwrap();
println!("{}", string);

Get a reference to the name of the S3 bucket.

Get a reference to the hostname of the S3 API endpoint.

Get the region this object will connect to.

Get a reference to the AWS access key.

Get a reference to the AWS secret key.

Get a reference to the AWS token.

Get a reference to the full Credentials object used by this Bucket.

Change the credentials used by the Bucket, returning the existing credentials.

Add an extra header to send with requests to S3.

Add an extra header to send with requests. Note that the library already sets a number of headers - headers set with this method will be overridden by the library headers: * Host * Content-Type * Date * Content-Length * Authorization * X-Amz-Content-Sha256 * X-Amz-Date

Get a reference to the extra headers to be passed to the S3 API.

Get a mutable reference to the extra headers to be passed to the S3 API.

Add an extra query pair to the URL used for S3 API access.

Get a reference to the extra query pairs to be passed to the S3 API.

Get a mutable reference to the extra query pairs to be passed to the S3 API.

Trait Implementations

impl Clone for Bucket
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Bucket
[src]

Formats the value using the given formatter.

impl Eq for Bucket
[src]

impl PartialEq for Bucket
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.