Struct rusty_s3::Bucket [−][src]
An S3 bucket
Path style url
let endpoint = "https://s3-eu-west-1.amazonaws.com".parse().expect("endpoint is a valid Url"); let path_style = true; let name = String::from("rusty-s3"); let region = String::from("eu-west-1"); let bucket = Bucket::new(endpoint, path_style, name, region).expect("Url has a valid scheme and host"); assert_eq!(bucket.base_url().as_str(), "https://s3-eu-west-1.amazonaws.com/rusty-s3/"); assert_eq!(bucket.name(), "rusty-s3"); assert_eq!(bucket.region(), "eu-west-1"); assert_eq!(bucket.object_url("duck.jpg").expect("url is valid").as_str(), "https://s3-eu-west-1.amazonaws.com/rusty-s3/duck.jpg");
Domain style url
let endpoint = "https://s3-eu-west-1.amazonaws.com".parse().expect("endpoint is a valid Url"); let path_style = false; let name = String::from("rusty-s3"); let region = String::from("eu-west-1"); let bucket = Bucket::new(endpoint, path_style, name, region).expect("Url has a valid scheme and host"); assert_eq!(bucket.base_url().as_str(), "https://rusty-s3.s3-eu-west-1.amazonaws.com/"); assert_eq!(bucket.name(), "rusty-s3"); assert_eq!(bucket.region(), "eu-west-1"); assert_eq!(bucket.object_url("duck.jpg").expect("url is valid").as_str(), "https://rusty-s3.s3-eu-west-1.amazonaws.com/duck.jpg");
Implementations
impl Bucket[src]
pub fn new(
endpoint: Url,
path_style: bool,
name: String,
region: String
) -> Option<Self>[src]
endpoint: Url,
path_style: bool,
name: String,
region: String
) -> Option<Self>
Construct a new S3 bucket
pub fn base_url(&self) -> &Url[src]
Get the base url of this s3 Bucket
pub fn name(&self) -> &str[src]
Get the name of this Bucket
pub fn region(&self) -> &str[src]
Get the region of this Bucket
pub fn object_url(&self, object: &str) -> Result<Url, ParseError>[src]
Generate an url to an object of this Bucket
This is not a signed url, it’s just the starting point for generating an url to an S3 object.
impl Bucket[src]
pub fn create_bucket<'a>(
&'a self,
credentials: &'a Credentials
) -> CreateBucket<'a>[src]
&'a self,
credentials: &'a Credentials
) -> CreateBucket<'a>
Create a new bucket.
See CreateBucket for more details.
pub fn delete_bucket<'a>(
&'a self,
credentials: &'a Credentials
) -> DeleteBucket<'a>[src]
&'a self,
credentials: &'a Credentials
) -> DeleteBucket<'a>
Delete a bucket.
See DeleteBucket for more details.
impl Bucket[src]
pub fn get_object<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str
) -> GetObject<'a>[src]
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str
) -> GetObject<'a>
Retrieve an object from S3, using a GET request.
See GetObject for more details.
pub fn list_objects_v2<'a>(
&'a self,
credentials: Option<&'a Credentials>
) -> ListObjectsV2<'a>[src]
&'a self,
credentials: Option<&'a Credentials>
) -> ListObjectsV2<'a>
List all objects in the bucket.
See ListObjectsV2 for more details.
pub fn put_object<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str
) -> PutObject<'a>[src]
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str
) -> PutObject<'a>
Upload a file to S3, using a PUT request.
See PutObject for more details.
pub fn delete_object<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str
) -> DeleteObject<'a>[src]
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str
) -> DeleteObject<'a>
Delete an object from S3, using a DELETE request.
See DeleteObject for more details.
impl Bucket[src]
pub fn create_multipart_upload<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str
) -> CreateMultipartUpload<'a>[src]
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str
) -> CreateMultipartUpload<'a>
Create a multipart upload.
See CreateMultipartUpload for more details.
pub fn upload_part<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
part_number: u16,
upload_id: &'a str
) -> UploadPart<'a>[src]
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
part_number: u16,
upload_id: &'a str
) -> UploadPart<'a>
Upload a part to a previously created multipart upload.
See UploadPart for more details.
pub fn complete_multipart_upload<'a, I>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
upload_id: &'a str,
etags: I
) -> CompleteMultipartUpload<'a, I>[src]
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
upload_id: &'a str,
etags: I
) -> CompleteMultipartUpload<'a, I>
Complete a multipart upload.
See CompleteMultipartUpload for more details.
pub fn abort_multipart_upload<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
upload_id: &'a str
) -> AbortMultipartUpload<'a>[src]
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
upload_id: &'a str
) -> AbortMultipartUpload<'a>
Abort multipart upload.
See AbortMultipartUpload for more details.
Trait Implementations
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,
pub fn borrow_mut(&mut self) -> &mut T[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.
pub fn to_owned(&self) -> T[src]
pub 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.
pub 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>,