[−][src]Struct s3::bucket::Bucket
Example
use s3::bucket::Bucket; use awscreds::Credentials; let bucket_name = "rust-s3-test"; let region = "us-east-1".parse().unwrap(); let credentials = Credentials::default_blocking().unwrap(); let bucket = Bucket::new(bucket_name, region, credentials);
Fields
name: String
region: Region
credentials: Credentials
extra_headers: Headers
extra_query: Query
Implementations
impl Bucket
[src]
pub fn new(
name: &str,
region: Region,
credentials: Credentials
) -> Result<Bucket>
[src]
name: &str,
region: Region,
credentials: Credentials
) -> Result<Bucket>
Instantiate a new Bucket
.
Example
use s3::bucket::Bucket; use awscreds::Credentials; let bucket_name = "rust-s3-test"; let region = "us-east-1".parse().unwrap(); let credentials = Credentials::default_blocking().unwrap(); let bucket = Bucket::new(bucket_name, region, credentials).unwrap();
pub fn new_public(name: &str, region: Region) -> Result<Bucket>
[src]
pub fn get_object_blocking<S: AsRef<str>>(
&self,
path: S
) -> Result<(Vec<u8>, u16)>
[src]
&self,
path: S
) -> Result<(Vec<u8>, u16)>
Gets file from an S3 path, blocks.
Example:
use s3::bucket::Bucket; use awscreds::Credentials; let bucket_name = "rust-s3-test"; let region = "us-east-1".parse().unwrap(); let credentials = Credentials::default_blocking().unwrap(); let bucket = Bucket::new(bucket_name, region, credentials).unwrap(); let (data, code) = bucket.get_object_blocking("/test.file").unwrap(); println!("Code: {}\nData: {:?}", code, data);
pub async fn get_object<'_, S: AsRef<str>>(
&'_ self,
path: S
) -> Result<(Vec<u8>, u16)>
[src]
&'_ self,
path: S
) -> Result<(Vec<u8>, u16)>
Gets file from an S3 path, async.
Example:
use s3::bucket::Bucket; use awscreds::Credentials; use s3::S3Error; #[tokio::main] async fn main() -> Result<(), S3Error> { let bucket_name = "rust-s3-test"; let region = "us-east-1".parse()?; let credentials = Credentials::default().await?; let bucket = Bucket::new(bucket_name, region, credentials)?; let (data, code) = bucket.get_object("/test.file").await?; println!("Code: {}", code); println!("{:?}", data); Ok(()) }
pub fn get_object_stream_blocking<T: Write>(
&self,
path: &str,
writer: &mut T
) -> Result<u16>
[src]
&self,
path: &str,
writer: &mut T
) -> Result<u16>
Stream file from S3 path to a local file, generic over T: Write, blocks.
Example:
use s3::bucket::Bucket; use awscreds::Credentials; use std::fs::File; let bucket_name = "rust-s3-test"; let region = "us-east-1".parse().unwrap(); let credentials = Credentials::default_blocking().unwrap(); let bucket = Bucket::new(bucket_name, region, credentials).unwrap(); let mut output_file = File::create("output_file").expect("Unable to create file"); let code = bucket.get_object_stream_blocking("/test.file", &mut output_file).unwrap(); println!("Code: {}", code);
pub async fn get_object_stream<'_, '_, T: Write, S: AsRef<str>>(
&'_ self,
path: S,
writer: &'_ mut T
) -> Result<u16>
[src]
&'_ self,
path: S,
writer: &'_ mut T
) -> Result<u16>
Stream file from S3 path to a local file, generic over T: Write, async.
Example:
use s3::bucket::Bucket; use awscreds::Credentials; use s3::S3Error; use std::fs::File; #[tokio::main] async fn main() -> Result<(), S3Error> { let bucket_name = "rust-s3-test"; let region = "us-east-1".parse()?; let credentials = Credentials::default().await?; let bucket = Bucket::new(bucket_name, region, credentials)?; let mut output_file = File::create("output_file").expect("Unable to create file"); let status_code = bucket.get_object_stream("/test.file", &mut output_file).await?; println!("Code: {}", status_code); Ok(()) }
pub async fn tokio_get_object_stream<'_, '_, T: AsyncWriteExt + Unpin, S: AsRef<str>>(
&'_ self,
path: S,
writer: &'_ mut T
) -> Result<u16>
[src]
&'_ self,
path: S,
writer: &'_ mut T
) -> Result<u16>
Stream file from S3 path to a local file, generic over T: Write, async.
Example:
use s3::bucket::Bucket; use awscreds::Credentials; use s3::S3Error; use std::fs::File; #[tokio::main] async fn main() -> Result<(), S3Error> { let bucket_name = "rust-s3-test"; let region = "us-east-1".parse()?; let credentials = Credentials::default().await?; let bucket = Bucket::new(bucket_name, region, credentials)?; let mut output_file = File::create("output_file").expect("Unable to create file"); let status_code = bucket.get_object_stream("/test.file", &mut output_file).await?; println!("Code: {}", status_code); Ok(()) }
pub async fn put_object_stream<'_, '_, R: Read, S: AsRef<str>>(
&'_ self,
reader: &'_ mut R,
s3_path: S
) -> Result<u16>
[src]
&'_ self,
reader: &'_ mut R,
s3_path: S
) -> Result<u16>
Stream file from local path to s3, async.
Example:
use s3::bucket::Bucket; use awscreds::Credentials; use s3::S3Error; use std::fs::File; #[tokio::main] async fn main() -> Result<(), S3Error> { let bucket_name = "rust-s3-test"; let region = "us-east-1".parse()?; let credentials = Credentials::default().await?; let bucket = Bucket::new(bucket_name, region, credentials)?; let mut file = File::open("foo.txt")?; let status_code = bucket.put_object_stream(&mut file, "/test_file").await?; println!("Code: {}", status_code); Ok(()) }
pub async fn tokio_put_object_stream<'_, '_, R: AsyncReadExt + Unpin, S: AsRef<str>>(
&'_ self,
reader: &'_ mut R,
s3_path: S
) -> Result<u16>
[src]
&'_ self,
reader: &'_ mut R,
s3_path: S
) -> Result<u16>
Stream file from local path to s3 using tokio::io, async.
Example:
use s3::bucket::Bucket; use awscreds::Credentials; use s3::S3Error; use std::fs::File; #[tokio::main] async fn main() -> Result<(), S3Error> { let bucket_name = "rust-s3-test"; let region = "us-east-1".parse()?; let credentials = Credentials::default().await?; let bucket = Bucket::new(bucket_name, region, credentials)?; let mut file = File::open("foo.txt")?; let status_code = bucket.put_object_stream(&mut file, "/test_file").await?; println!("Code: {}", status_code); Ok(()) }
pub fn put_object_stream_blocking<R: Read, S: AsRef<str>>(
&self,
reader: &mut R,
s3_path: S
) -> Result<u16>
[src]
&self,
reader: &mut R,
s3_path: S
) -> Result<u16>
Stream file from local path to s3, blockIng.
Example:
use s3::bucket::Bucket; use awscreds::Credentials; use s3::S3Error; use std::fs::File; fn main() -> Result<(), S3Error> { let bucket_name = "rust-s3-test"; let region = "us-east-1".parse()?; let credentials = Credentials::default_blocking()?; let bucket = Bucket::new(bucket_name, region, credentials)?; let mut file = File::open("foo.txt")?; let status_code = bucket.put_object_stream_blocking(&mut file, "/test_file")?; println!("Code: {}", status_code); Ok(()) }
pub async fn location<'_>(&'_ self) -> Result<(Region, u16)>
[src]
Example
use s3::bucket::Bucket; use awscreds::Credentials; use s3::S3Error; #[tokio::main] async fn main() -> Result<(), S3Error> { let bucket_name = "rust-s3-test"; let region = "eu-central-1".parse()?; let credentials = Credentials::default().await?; let bucket = Bucket::new(bucket_name, region, credentials)?; println!("{}", bucket.location().await?.0); Ok(()) }
pub fn location_blocking(&self) -> Result<(Region, u16)>
[src]
Example
use s3::bucket::Bucket; use awscreds::Credentials; let bucket_name = "rust-s3-test"; let region = "eu-central-1".parse().unwrap(); let credentials = Credentials::default_blocking().unwrap(); let bucket = Bucket::new(bucket_name, region, credentials).unwrap(); println!("{}", bucket.location_blocking().unwrap().0)
pub async fn delete_object<'_, S: AsRef<str>>(
&'_ self,
path: S
) -> Result<(Vec<u8>, u16)>
[src]
&'_ self,
path: S
) -> Result<(Vec<u8>, u16)>
Delete file from an S3 path, async.
Example:
use s3::bucket::Bucket; use awscreds::Credentials; use s3::S3Error; #[tokio::main] async fn main() -> Result<(), S3Error> { let bucket_name = &"rust-s3-test"; let region = "us-east-1".parse()?; let credentials = Credentials::default().await?; let bucket = Bucket::new(bucket_name, region, credentials)?; let (_, code) = bucket.delete_object("/test.file").await?; assert_eq!(204, code); Ok(()) }
pub fn delete_object_blocking<S: AsRef<str>>(
&self,
path: S
) -> Result<(Vec<u8>, u16)>
[src]
&self,
path: S
) -> Result<(Vec<u8>, u16)>
Delete file from an S3 path, blocks .
Example:
use s3::bucket::Bucket; use awscreds::Credentials; let bucket_name = &"rust-s3-test"; let region = "us-east-1".parse().unwrap(); let credentials = Credentials::default_blocking().unwrap(); let bucket = Bucket::new(bucket_name, region, credentials).unwrap(); let (_, code) = bucket.delete_object_blocking("/test.file").unwrap(); assert_eq!(204, code);
pub async fn put_object<'_, '_, '_, S: AsRef<str>>(
&'_ self,
path: S,
content: &'_ [u8],
content_type: &'_ str
) -> Result<(Vec<u8>, u16)>
[src]
&'_ self,
path: S,
content: &'_ [u8],
content_type: &'_ str
) -> Result<(Vec<u8>, u16)>
Put into an S3 bucket, async.
Example
use s3::bucket::Bucket; use awscreds::Credentials; use s3::S3Error; #[tokio::main] async fn main() -> Result<(), S3Error> { 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_blocking().unwrap(); let bucket = Bucket::new(bucket_name, region, credentials).unwrap(); let content = "I want to go to S3".as_bytes(); let (_, code) = bucket.put_object("/test.file", content, "text/plain").await?; assert_eq!(201, code); Ok(()) }
pub fn put_object_blocking<S: AsRef<str>>(
&self,
path: S,
content: &[u8],
content_type: &str
) -> Result<(Vec<u8>, u16)>
[src]
&self,
path: S,
content: &[u8],
content_type: &str
) -> Result<(Vec<u8>, u16)>
Put into an S3 bucket, blocks.
Example
use s3::bucket::Bucket; use awscreds::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_blocking().unwrap(); let bucket = Bucket::new(bucket_name, region, credentials).unwrap(); let content = "I want to go to S3".as_bytes(); let (_, code) = bucket.put_object_blocking("/test.file", content, "text/plain").unwrap(); assert_eq!(201, code);
pub async fn put_object_tagging<'_, '_, '_, S: AsRef<str>>(
&'_ self,
path: &'_ str,
tags: &'_ [(S, S)]
) -> Result<(Vec<u8>, u16)>
[src]
&'_ self,
path: &'_ str,
tags: &'_ [(S, S)]
) -> Result<(Vec<u8>, u16)>
Tag an S3 object, async.
Example
use s3::bucket::Bucket; use awscreds::Credentials; use s3::S3Error; #[tokio::main] async fn main() -> Result<(), S3Error> { 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()?; let credentials = Credentials::default().await?; let bucket = Bucket::new(bucket_name, region, credentials)?; let (_, code) = bucket.put_object_tagging("/test.file", &[("Tag1", "Value1"), ("Tag2", "Value2")]).await?; assert_eq!(201, code); Ok(()) }
pub fn put_object_tagging_blocking<S: AsRef<str>>(
&self,
path: &str,
tags: &[(S, S)]
) -> Result<(Vec<u8>, u16)>
[src]
&self,
path: &str,
tags: &[(S, S)]
) -> Result<(Vec<u8>, u16)>
Tag an S3 object, blocks.
Example
use s3::bucket::Bucket; use awscreds::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_blocking().unwrap(); let bucket = Bucket::new(bucket_name, region, credentials).unwrap(); let (_, code) = bucket.put_object_tagging_blocking("/test.file", &[("Tag1", "Value1"), ("Tag2", "Value2")]).unwrap(); assert_eq!(201, code);
pub async fn delete_object_tagging<'_, S: AsRef<str>>(
&'_ self,
path: S
) -> Result<(Vec<u8>, u16)>
[src]
&'_ self,
path: S
) -> Result<(Vec<u8>, u16)>
Delete tags from an S3 object, async.
Example
use s3::bucket::Bucket; use awscreds::Credentials; use s3::S3Error; #[tokio::main] async fn main() -> Result<(), S3Error> { 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()?; let credentials = Credentials::default().await?; let bucket = Bucket::new(bucket_name, region, credentials)?; let (_, code) = bucket.delete_object_tagging("/test.file").await?; assert_eq!(201, code); Ok(()) }
pub fn delete_object_tagging_blocking<S: AsRef<str>>(
&self,
path: S
) -> Result<(Vec<u8>, u16)>
[src]
&self,
path: S
) -> Result<(Vec<u8>, u16)>
Delete tags from an S3 object, blocks.
Example
use s3::bucket::Bucket; use awscreds::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_blocking().unwrap(); let bucket = Bucket::new(bucket_name, region, credentials).unwrap(); let (_, code) = bucket.delete_object_tagging_blocking("/test.file").unwrap(); assert_eq!(201, code);
pub async fn get_object_tagging<'_, S: AsRef<str>>(
&'_ self,
path: S
) -> Result<(Option<Tagging>, u16)>
[src]
&'_ self,
path: S
) -> Result<(Option<Tagging>, u16)>
Retrieve an S3 object list of tags, async.
Example
use s3::bucket::Bucket; use awscreds::Credentials; use s3::S3Error; #[tokio::main] async fn main() -> Result<(), S3Error> { 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()?; let credentials = Credentials::default().await?; let bucket = Bucket::new(bucket_name, region, credentials)?; let (tags, code) = bucket.get_object_tagging("/test.file").await?; if code == 200 { for tag in tags.expect("No tags found").tag_set { println!("{}={}", tag.key(), tag.value()); } } Ok(()) }
pub fn get_object_tagging_blocking<S: AsRef<str>>(
&self,
path: S
) -> Result<(Option<Tagging>, u16)>
[src]
&self,
path: S
) -> Result<(Option<Tagging>, u16)>
Retrieve an S3 object list of tags, blocks.
Example
use s3::bucket::Bucket; use awscreds::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_blocking().unwrap(); let bucket = Bucket::new(bucket_name, region, credentials).unwrap(); let (tags, code) = bucket.get_object_tagging_blocking("/test.file").unwrap(); if code == 200 { for tag in tags.expect("No tags found").tag_set { println!("{}={}", tag.key(), tag.value()); } }
pub fn list_page_blocking(
&self,
prefix: String,
delimiter: Option<String>,
continuation_token: Option<String>
) -> Result<(ListBucketResult, u16)>
[src]
&self,
prefix: String,
delimiter: Option<String>,
continuation_token: Option<String>
) -> Result<(ListBucketResult, u16)>
pub async fn list_page<'_>(
&'_ self,
prefix: String,
delimiter: Option<String>,
continuation_token: Option<String>
) -> Result<(ListBucketResult, u16)>
[src]
&'_ self,
prefix: String,
delimiter: Option<String>,
continuation_token: Option<String>
) -> Result<(ListBucketResult, u16)>
pub fn list_blocking(
&self,
prefix: String,
delimiter: Option<String>
) -> Result<Vec<(ListBucketResult, u16)>>
[src]
&self,
prefix: String,
delimiter: Option<String>
) -> Result<Vec<(ListBucketResult, u16)>>
List the contents of an S3 bucket, blocks.
Example
use std::str; use s3::bucket::Bucket; use awscreds::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_blocking().unwrap(); let bucket = Bucket::new(bucket_name, region, credentials).unwrap(); let results = bucket.list_blocking("/".to_string(), Some("/".to_string())).unwrap(); for (list, code) in results { assert_eq!(200, code); println!("{:?}", list); }
pub async fn list<'_>(
&'_ self,
prefix: String,
delimiter: Option<String>
) -> Result<Vec<ListBucketResult>>
[src]
&'_ self,
prefix: String,
delimiter: Option<String>
) -> Result<Vec<ListBucketResult>>
List the contents of an S3 bucket, async.
Example
extern crate futures; use std::str; use s3::bucket::Bucket; use awscreds::Credentials; use s3::S3Error; #[tokio::main] async fn main() -> Result<(), S3Error> { 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()?; let credentials = Credentials::default().await?; let bucket = Bucket::new(bucket_name, region, credentials)?; let results = bucket.list("/".to_string(), Some("/".to_string())).await?; println!("{:?}", results); Ok(()) }
pub fn name(&self) -> String
[src]
Get a reference to the name of the S3 bucket.
pub fn host(&self) -> String
[src]
Get a reference to the hostname of the S3 API endpoint.
pub fn self_host(&self) -> String
[src]
pub fn scheme(&self) -> String
[src]
pub fn region(&self) -> Region
[src]
Get the region this object will connect to.
pub fn access_key(&self) -> Option<String>
[src]
Get a reference to the AWS access key.
pub fn secret_key(&self) -> Option<String>
[src]
Get a reference to the AWS secret key.
pub fn security_token(&self) -> Option<&str>
[src]
Get a reference to the AWS security token.
pub fn session_token(&self) -> Option<&str>
[src]
Get a reference to the AWS session token.
pub fn credentials(&self) -> &Credentials
[src]
Get a reference to the full Credentials
object used by this Bucket
.
pub fn set_credentials(&mut self, credentials: Credentials) -> Credentials
[src]
Change the credentials used by the Bucket, returning the existing credentials.
pub fn add_header(&mut self, key: &str, value: &str)
[src]
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
pub fn extra_headers(&self) -> &Headers
[src]
Get a reference to the extra headers to be passed to the S3 API.
pub fn extra_headers_mut(&mut self) -> &mut Headers
[src]
Get a mutable reference to the extra headers to be passed to the S3 API.
pub fn add_query(&mut self, key: &str, value: &str)
[src]
Add an extra query pair to the URL used for S3 API access.
pub fn extra_query(&self) -> &Query
[src]
Get a reference to the extra query pairs to be passed to the S3 API.
pub fn extra_query_mut(&mut self) -> &mut Query
[src]
Get a mutable reference to the extra query pairs to be passed to the S3 API.
Trait Implementations
impl Clone for Bucket
[src]
impl Debug for Bucket
[src]
impl Eq for Bucket
[src]
impl PartialEq<Bucket> for Bucket
[src]
impl StructuralEq for Bucket
[src]
impl StructuralPartialEq for Bucket
[src]
Auto Trait Implementations
impl RefUnwindSafe for Bucket
impl Send for Bucket
impl Sync for Bucket
impl Unpin for Bucket
impl UnwindSafe for Bucket
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,