pub struct Bucket { /* private fields */ }Expand description
An OSS bucket
§Domain style url
let endpoint = "https://oss-cn-hangzhou.aliyuncs.com".parse().expect("endpoint is a valid Url");
let path_style = UrlStyle::VirtualHost;
let name = "examplebucket";
let region = "cn-hangzhou";
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://examplebucket.oss-cn-hangzhou.aliyuncs.com/");
assert_eq!(bucket.name(), "examplebucket");
assert_eq!(bucket.region(), "cn-hangzhou");
assert_eq!(bucket.object_url("duck.jpg").expect("url is valid").as_str(), "https://examplebucket.oss-cn-hangzhou.aliyuncs.com/duck.jpg");Implementations§
Source§impl Bucket
impl Bucket
Sourcepub fn new(
endpoint: Url,
path_style: UrlStyle,
name: impl Into<Cow<'static, str>>,
region: impl Into<Cow<'static, str>>,
) -> Result<Self, BucketError>
pub fn new( endpoint: Url, path_style: UrlStyle, name: impl Into<Cow<'static, str>>, region: impl Into<Cow<'static, str>>, ) -> Result<Self, BucketError>
Construct a new OSS bucket
§Errors
Returns a BucketError if the endpoint is not a valid url, or if the endpoint is missing the host.
Sourcepub fn object_url(&self, object: &str) -> Result<Url, ParseError>
pub fn object_url(&self, object: &str) -> Result<Url, ParseError>
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 OSS object.
§Errors
Returns a ParseError if the object is not a valid path.
Source§impl Bucket
impl Bucket
Sourcepub fn create_bucket<'a>(
&'a self,
credentials: &'a Credentials,
) -> CreateBucket<'a>
pub fn create_bucket<'a>( &'a self, credentials: &'a Credentials, ) -> CreateBucket<'a>
Create a new bucket.
See CreateBucket for more details.
Sourcepub fn delete_bucket<'a>(
&'a self,
credentials: &'a Credentials,
) -> DeleteBucket<'a>
pub fn delete_bucket<'a>( &'a self, credentials: &'a Credentials, ) -> DeleteBucket<'a>
Delete a bucket.
See DeleteBucket for more details.
Source§impl Bucket
impl Bucket
Sourcepub fn head_object<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
) -> HeadObject<'a>
pub fn head_object<'a>( &'a self, credentials: Option<&'a Credentials>, object: &'a str, ) -> HeadObject<'a>
Retrieve an object’s metadata from OSS, using a HEAD request.
See HeadObject for more details.
Sourcepub fn head_bucket<'a>(
&'a self,
credentials: Option<&'a Credentials>,
) -> HeadBucket<'a>
pub fn head_bucket<'a>( &'a self, credentials: Option<&'a Credentials>, ) -> HeadBucket<'a>
Retrieve an bucket’s metadata from OSS, using a HEAD request.
See HeadBucket for more details.
Sourcepub fn get_object<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
) -> GetObject<'a>
pub fn get_object<'a>( &'a self, credentials: Option<&'a Credentials>, object: &'a str, ) -> GetObject<'a>
Retrieve an object from OSS, using a GET request.
See GetObject for more details.
Sourcepub fn list_objects_v2<'a>(
&'a self,
credentials: Option<&'a Credentials>,
) -> ListObjectsV2<'a>
pub fn list_objects_v2<'a>( &'a self, credentials: Option<&'a Credentials>, ) -> ListObjectsV2<'a>
List all objects in the bucket.
See ListObjectsV2 for more details.
Sourcepub fn put_object<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
) -> PutObject<'a>
pub fn put_object<'a>( &'a self, credentials: Option<&'a Credentials>, object: &'a str, ) -> PutObject<'a>
Upload a file to OSS, using a PUT request.
See PutObject for more details.
Sourcepub fn delete_object<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
) -> DeleteObject<'a>
pub fn delete_object<'a>( &'a self, credentials: Option<&'a Credentials>, object: &'a str, ) -> DeleteObject<'a>
Delete an object from OSS, using a DELETE request.
See DeleteObject for more details.
Sourcepub fn delete_objects<'a, I>(
&'a self,
credentials: Option<&'a Credentials>,
objects: I,
) -> DeleteObjects<'a, I>
pub fn delete_objects<'a, I>( &'a self, credentials: Option<&'a Credentials>, objects: I, ) -> DeleteObjects<'a, I>
Delete multiple objects from OSS using a single POST request.
See DeleteObjects for more details.
Source§impl Bucket
impl Bucket
Sourcepub fn create_multipart_upload<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
) -> CreateMultipartUpload<'a>
pub fn create_multipart_upload<'a>( &'a self, credentials: Option<&'a Credentials>, object: &'a str, ) -> CreateMultipartUpload<'a>
Create a multipart upload.
See CreateMultipartUpload for more details.
Sourcepub fn upload_part<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
part_number: u16,
upload_id: &'a str,
) -> UploadPart<'a>
pub fn upload_part<'a>( &'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.
Sourcepub fn complete_multipart_upload<'a, I>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
upload_id: &'a str,
etags: I,
) -> CompleteMultipartUpload<'a, I>
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>
Complete a multipart upload.
See CompleteMultipartUpload for more details.
Sourcepub fn abort_multipart_upload<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
upload_id: &'a str,
) -> AbortMultipartUpload<'a>
pub fn abort_multipart_upload<'a>( &'a self, credentials: Option<&'a Credentials>, object: &'a str, upload_id: &'a str, ) -> AbortMultipartUpload<'a>
Abort multipart upload.
See AbortMultipartUpload for more details.
Sourcepub fn list_parts<'a>(
&'a self,
credentials: Option<&'a Credentials>,
object: &'a str,
upload_id: &'a str,
) -> ListParts<'a>
pub fn list_parts<'a>( &'a self, credentials: Option<&'a Credentials>, object: &'a str, upload_id: &'a str, ) -> ListParts<'a>
Lists the parts that have been uploaded for a specific multipart upload.
See ListParts for more details.