Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

An synchronous OSS client which requesting aliyun OSS api in blocking mode.

Implementations§

Source§

impl Client

Source

pub fn presign_url<S1, S2>( &self, bucket_name: S1, object_key: S2, options: PresignGetOptions, ) -> String
where S1: AsRef<str>, S2: AsRef<str>,

Presign URL for GET request without any additional headers supported, for brower mostly

Source

pub fn presign_raw_request(&self, oss_request: OssRequest) -> SignedOssRequest

Source§

impl Client

Source

pub fn from_env() -> Self

Creates a new client from environment variables.

  • ALI_ACCESS_KEY_ID The access key id
  • ALI_ACCESS_KEY_SECRET The access key secret
  • ALI_OSS_ENDPOINT The endpoint of the OSS service. e.g. oss-cn-hangzhou.aliyuncs.com. Or, you can write full URL http://oss-cn-hangzhou.aliyuncs.com or https://oss-cn-hangzhou.aliyuncs.com with scheme http or https.
  • ALI_OSS_REGION Optional. The region of the OSS service. If not present, It will be inferred from the ALI_OSS_ENDPOINT env.
Source

pub fn new<S1, S2, S3, S4>( access_key_id: S1, access_key_secret: S2, region: S3, endpoint: S4, ) -> Self
where S1: AsRef<str>, S2: AsRef<str>, S3: AsRef<str>, S4: AsRef<str>,

Source

pub fn clone_to<S1, S2>(&self, region: S1, endpoint: S2) -> Self
where S1: AsRef<str>, S2: AsRef<str>,

Clone a new client instance with the same security data and different region. This is helpful if you are operation on buckets across multiple regions with a single pair of access key id and secret.

Trait Implementations§

Source§

impl BucketOperations for Client

Source§

fn put_bucket<S: AsRef<str>>( &self, bucket_name: S, config: PutBucketConfiguration, options: Option<PutBucketOptions>, ) -> Result<()>

Source§

fn list_buckets( &self, options: Option<ListBucketsOptions>, ) -> Result<ListBucketsResult>

Source§

fn get_bucket_info<S: AsRef<str>>(&self, bucket_name: S) -> Result<BucketDetail>

Source§

fn get_bucket_location<S: AsRef<str>>(&self, bucket_name: S) -> Result<String>

Source§

fn get_bucket_stat<S: AsRef<str>>(&self, bucket_name: S) -> Result<BucketStat>

Source§

fn list_objects<S: AsRef<str>>( &self, bucket_name: S, options: Option<ListObjectsOptions>, ) -> Result<ListObjectsResult>

Source§

fn delete_bucket<S: AsRef<str>>(&self, bucket_name: S) -> Result<()>

Source§

impl CnameOperations for Client

Source§

impl MultipartUploadsOperations for Client

Source§

fn list_multipart_uploads<S>( &self, bucket_name: S, options: Option<ListMultipartUploadsOptions>, ) -> Result<ListMultipartUploadsResult>
where S: AsRef<str>,

List multipart uploads which are initialized but not completed nor aborted.

Official document: https://help.aliyun.com/zh/oss/developer-reference/listmultipartuploads

Source§

fn list_parts<S1, S2, S3>( &self, bucket_name: S1, object_key: S2, upload_id: S3, options: Option<ListPartsOptions>, ) -> Result<ListPartsResult>
where S1: AsRef<str>, S2: AsRef<str>, S3: AsRef<str>,

List parts which uploaded successfully associated with the given upload_id

Official document: https://help.aliyun.com/zh/oss/developer-reference/listparts

Source§

fn initiate_multipart_uploads<S1, S2>( &self, bucket_name: S1, object_key: S2, options: Option<InitiateMultipartUploadOptions>, ) -> Result<InitiateMultipartUploadResult>
where S1: AsRef<str>, S2: AsRef<str>,

Source§

fn upload_part_from_file<S1, S2, P>( &self, bucket_name: S1, object_key: S2, file_path: P, range: Range<u64>, params: UploadPartRequest, ) -> Result<UploadPartResult>
where S1: AsRef<str>, S2: AsRef<str>, P: AsRef<Path>,

Upload part of a file. the caller should take responsibility to make sure the range is valid.

Official document: https://help.aliyun.com/zh/oss/developer-reference/uploadpart

Source§

fn upload_part_from_buffer<S1, S2, B>( &self, bucket_name: S1, object_key: S2, buffer: B, params: UploadPartRequest, ) -> Result<UploadPartResult>
where S1: AsRef<str>, S2: AsRef<str>, B: Into<Vec<u8>>,

Upload part from buffer.

Official document: https://help.aliyun.com/zh/oss/developer-reference/uploadpart

Source§

fn upload_part_from_base64<S1, S2, S3>( &self, bucket_name: S1, object_key: S2, base64_string: S3, params: UploadPartRequest, ) -> Result<UploadPartResult>
where S1: AsRef<str>, S2: AsRef<str>, S3: AsRef<str>,

Upload part from base64 string.

Official document: https://help.aliyun.com/zh/oss/developer-reference/uploadpart

Source§

fn upload_part_copy<S1, S2>( &self, bucket_name: S1, dest_object_key: S2, data: UploadPartCopyRequest, options: Option<UploadPartCopyOptions>, ) -> Result<UploadPartCopyResult>
where S1: AsRef<str>, S2: AsRef<str>,

When you want to copy a file larger than 1GB, you must use upload_part_copy. First, initiate a multipart upload and get uploadId, then call this method to upload parts of the source object. Finally complete the multipart upload by invoking complete_multipart_uploads

Offical document: https://help.aliyun.com/zh/oss/developer-reference/uploadpartcopy

Source§

fn complete_multipart_uploads<S1, S2>( &self, bucket_name: S1, object_key: S2, data: CompleteMultipartUploadRequest, options: Option<CompleteMultipartUploadOptions>, ) -> Result<CompleteMultipartUploadResult>
where S1: AsRef<str>, S2: AsRef<str>,

Source§

fn abort_multipart_uploads<S1, S2, S3>( &self, bucket_name: S1, object_key: S2, upload_id: S3, ) -> Result<()>
where S1: AsRef<str>, S2: AsRef<str>, S3: AsRef<str>,

Source§

impl ObjectAclOperations for Client

Source§

fn get_object_acl<S1, S2>( &self, bucket_name: S1, object_key: S2, options: Option<GetObjectAclOptions>, ) -> Result<ObjectAcl>
where S1: AsRef<str>, S2: AsRef<str>,

Get an object’s acl.

Official document: https://help.aliyun.com/zh/oss/developer-reference/getobjectacl

Source§

fn put_object_acl<S1, S2>( &self, bucket_name: S1, object_key: S2, acl: ObjectAcl, options: Option<GetObjectAclOptions>, ) -> Result<()>
where S1: AsRef<str>, S2: AsRef<str>,

Put an object’s acl. If you want to restore the object’s acl to follow bucket acl settings, pass acl as ObjectAcl::Default

Official document: https://help.aliyun.com/zh/oss/developer-reference/putobjectacl

Source§

impl ObjectOperations for Client

Source§

fn put_object_from_file<S1, S2, P>( &self, bucket_name: S1, object_key: S2, file_path: P, options: Option<PutObjectOptions>, ) -> Result<PutObjectResult>
where S1: AsRef<str>, S2: AsRef<str>, P: AsRef<Path>,

Uploads a file to a specified bucket and object key.

Official document: https://help.aliyun.com/zh/oss/developer-reference/putobject

Source§

fn put_object_from_buffer<S1, S2, B>( &self, bucket_name: S1, object_key: S2, buffer: B, options: Option<PutObjectOptions>, ) -> Result<PutObjectResult>
where S1: AsRef<str>, S2: AsRef<str>, B: Into<Vec<u8>>,

Create an object from buffer. If you are going to upload a large file, it is recommended to use upload_file instead. And, it is recommended to set mime_type in options

Official document: https://help.aliyun.com/zh/oss/developer-reference/putobject

Source§

fn put_object_from_base64<S1, S2, S3>( &self, bucket_name: S1, object_key: S2, base64_string: S3, options: Option<PutObjectOptions>, ) -> Result<PutObjectResult>
where S1: AsRef<str>, S2: AsRef<str>, S3: AsRef<str>,

Create an object from base64 string. And, it is recommended to set mime_type in options

Official document: https://help.aliyun.com/zh/oss/developer-reference/putobject

Source§

fn append_object_from_file<S1, S2, P>( &self, bucket_name: S1, object_key: S2, file_path: P, position: u64, options: Option<AppendObjectOptions>, ) -> Result<AppendObjectResult>
where S1: AsRef<str>, S2: AsRef<str>, P: AsRef<Path>,

Source§

fn append_object_from_buffer<S1, S2, B>( &self, bucket_name: S1, object_key: S2, buffer: B, position: u64, options: Option<AppendObjectOptions>, ) -> Result<AppendObjectResult>
where S1: AsRef<str>, S2: AsRef<str>, B: Into<Vec<u8>>,

Append object from buffer. suitable for small size content And, it is recommended to set mime_type in options

Official document: https://help.aliyun.com/zh/oss/developer-reference/putobject

Source§

fn append_object_from_base64<S1, S2, S3>( &self, bucket_name: S1, object_key: S2, base64_string: S3, position: u64, options: Option<AppendObjectOptions>, ) -> Result<AppendObjectResult>
where S1: AsRef<str>, S2: AsRef<str>, S3: AsRef<str>,

Append object from base64 string. suitable for small size content And, it is recommended to set mime_type in options

Official document: https://help.aliyun.com/zh/oss/developer-reference/putobject

Source§

fn get_object_to_file<S1, S2, P>( &self, bucket_name: S1, object_key: S2, file_path: P, options: Option<GetObjectOptions>, ) -> Result<GetObjectResult>
where S1: AsRef<str>, S2: AsRef<str>, P: AsRef<Path>,

Uploads a file to a specified bucket and object key.

Official document: https://help.aliyun.com/zh/oss/developer-reference/getobject

Source§

fn get_object_to_buffer<S1, S2>( &self, bucket_name: S1, object_key: S2, options: Option<GetObjectOptions>, ) -> Result<Vec<u8>>
where S1: AsRef<str> + Send, S2: AsRef<str> + Send,

Get object content into memory (bytes array).

Large files can consume significant memory, exercise caution when using this function.

Source§

fn create_folder<S1, S2>(&self, bucket_name: S1, object_key: S2) -> Result<()>
where S1: AsRef<str>, S2: AsRef<str>,

Create a “folder”

Official document: https://help.aliyun.com/zh/oss/developer-reference/putobject

Source§

fn delete_folder<S1, S2>(&self, bucket_name: S1, object_key: S2) -> Result<()>
where S1: AsRef<str>, S2: AsRef<str>,

Delete a “folder”. if the folder contains any object, it will not be deleted

Official document: https://help.aliyun.com/zh/oss/developer-reference/deleteobject

Source§

fn get_object_metadata<S1, S2>( &self, bucket_name: S1, object_key: S2, options: Option<GetObjectMetadataOptions>, ) -> Result<ObjectMetadata>
where S1: AsRef<str>, S2: AsRef<str>,

Source§

fn exists<S1, S2>( &self, bucket_name: S1, object_key: S2, options: Option<GetObjectMetadataOptions>, ) -> Result<bool>
where S1: AsRef<str>, S2: AsRef<str>,

Check if the object exists or not using get object metadata

Official document: https://help.aliyun.com/zh/oss/developer-reference/getobjectmeta

Source§

fn head_object<S1, S2>( &self, bucket_name: S1, object_key: S2, options: Option<HeadObjectOptions>, ) -> Result<ObjectMetadata>
where S1: AsRef<str>, S2: AsRef<str>,

Source§

fn copy_object<S1, S2, S3, S4>( &self, source_bucket_name: S1, source_object_key: S2, dest_bucket_name: S3, dest_object_key: S4, options: Option<CopyObjectOptions>, ) -> Result<CopyObjectResult>
where S1: AsRef<str>, S2: AsRef<str>, S3: AsRef<str>, S4: AsRef<str>,

Copy files (Objects) between the same or different Buckets within the same region.

Official document: https://help.aliyun.com/zh/oss/developer-reference/copyobject

Source§

fn delete_object<S1, S2>( &self, bucket_name: S1, object_key: S2, options: Option<DeleteObjectOptions>, ) -> Result<DeleteObjectResult>
where S1: AsRef<str>, S2: AsRef<str>,

Source§

fn delete_multiple_objects<S1, S2>( &self, bucket_name: S1, config: DeleteMultipleObjectsConfig<'_, S2>, ) -> Result<DeleteMultipleObjectsResult>
where S1: AsRef<str>, S2: AsRef<str>,

Source§

fn restore_object<S1, S2>( &self, bucket_name: S1, object_key: S2, config: RestoreObjectRequest, ) -> Result<RestoreObjectResult>
where S1: AsRef<str>, S2: AsRef<str>,

Source§

fn clean_restored_object<S1, S2>( &self, bucket_name: S1, object_key: S2, ) -> Result<()>
where S1: AsRef<str>, S2: AsRef<str>,

Source§

impl ObjectSymlinkOperations for Client

Put a symlink object.

target_object_key should be a full and valid object key.

Official document: https://help.aliyun.com/zh/oss/developer-reference/putsymlink

Get a symlink object. The returned string is the target object key

Official document: https://help.aliyun.com/zh/oss/developer-reference/getsymlink

Source§

impl ObjectTagOperations for Client

Source§

fn get_object_tags<S1, S2>( &self, bucket_name: S1, object_key: S2, options: Option<GetObjectTagOptions>, ) -> Result<HashMap<String, String>>
where S1: AsRef<str>, S2: AsRef<str>,

Source§

fn put_object_tags<S1, S2>( &self, bucket_name: S1, object_key: S2, tags: HashMap<String, String>, options: Option<PutObjectTagOptions>, ) -> Result<()>
where S1: AsRef<str>, S2: AsRef<str>,

Source§

fn delete_object_tags<S1, S2>( &self, bucket_name: S1, object_key: S2, options: Option<DeleteObjectTagOptions>, ) -> Result<()>
where S1: AsRef<str>, S2: AsRef<str>,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more