[][src]Struct s3::bucket::Bucket

pub struct Bucket {
    pub name: String,
    pub region: Region,
    pub credentials: Credentials,
    pub extra_headers: Headers,
    pub extra_query: Query,
}

Example

use s3::bucket::Bucket;
use s3::credentials::Credentials;

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::default();

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

Fields

Methods

impl Bucket
[src]

Instantiate a new Bucket.

Example

use s3::bucket::Bucket;
use s3::credentials::Credentials;

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::default();

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

Gets file from an S3 path.

Example:

use s3::bucket::Bucket;
use s3::credentials::Credentials;

let bucket_name = "rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::default();
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::Bucket;
use s3::credentials::Credentials;

let bucket_name = &"rust-s3-test";
let region = "us-east-1".parse().unwrap();
let credentials = Credentials::default();
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::Bucket;
use s3::credentials::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::default();
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::Bucket;
use s3::credentials::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::default();
let bucket = Bucket::new(bucket_name, region, credentials);

let results = bucket.list("/", Some("/")).unwrap();
for (list, code) in results {
    assert_eq!(200, code);
    println!("{:?}", list);
}

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 PartialEq<Bucket> for Bucket
[src]

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

This method tests for !=.

impl Clone for Bucket
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Eq for Bucket
[src]

impl Debug for Bucket
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Bucket

impl Sync for Bucket

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> Same for T

Should always be Self

impl<Q, K> Equivalent for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

Compare self to key and return true if they are equal.

impl<T> Erased for T