Skip to main content

OssClient

Struct OssClient 

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

OSS API client

Implementations§

Source§

impl OssClient

Source

pub async fn copy_object( &self, src_bucket: &str, object_key: &str, dest_bucket: &str, dest_key: Option<&str>, ) -> Result<ObjectDetails>

Server-side copy of an object using x-ads-copy-from header. Much more efficient than download+re-upload for same-region copies.

Source

pub async fn batch_copy_objects( &self, src_bucket: &str, dest_bucket: &str, object_keys: &[String], ) -> Result<BatchResult<ObjectDetails>>

Batch copy objects from one bucket to another with concurrent execution. Uses a semaphore to limit concurrency to 10 concurrent requests.

Source

pub async fn batch_rename_objects( &self, bucket: &str, renames: &[(String, String)], ) -> Result<BatchResult<ObjectDetails>>

Batch rename objects within a bucket (copy to new key, then delete old key). Uses a semaphore to limit concurrency to 10 concurrent requests.

Source§

impl OssClient

Source

pub async fn create_bucket( &self, bucket_key: &str, policy: RetentionPolicy, region: Region, ) -> Result<Bucket>

Create a new bucket

Source

pub async fn list_buckets(&self) -> Result<Vec<BucketItem>>

List all buckets from all regions

Queries US and EMEA regions concurrently with a per-region timeout to avoid hanging when one region is slow or unreachable.

Source

pub async fn list_buckets_streaming(&self) -> Vec<RegionResult>

List buckets from all regions, returning results per-region as they complete.

Uses tokio::select! so whichever region finishes first yields its RegionResult immediately. The caller can display partial results while waiting for slower regions.

Source

pub async fn get_bucket_details(&self, bucket_key: &str) -> Result<Bucket>

Get bucket details

Source

pub async fn delete_bucket(&self, bucket_key: &str) -> Result<()>

Delete a bucket

Source§

impl OssClient

Source

pub async fn upload_multipart( &self, bucket_key: &str, object_key: &str, file_path: &Path, resume: bool, ) -> Result<ObjectInfo>

Upload a large file using multipart upload with resume capability

Source§

impl OssClient

Source

pub async fn upload_object( &self, bucket_key: &str, object_key: &str, file_path: &Path, ) -> Result<ObjectInfo>

Upload a file to a bucket using S3 signed URLs Automatically uses multipart upload for files larger than 5MB

Source

pub async fn upload_object_with_options( &self, bucket_key: &str, object_key: &str, file_path: &Path, resume: bool, ) -> Result<ObjectInfo>

Upload a file with resume option If resume is true, will attempt to resume an interrupted upload

Source

pub async fn download_object( &self, bucket_key: &str, object_key: &str, output_path: &Path, ) -> Result<()>

Download an object from a bucket using S3 signed URLs (new API)

Source

pub async fn download_object_to_writer( &self, bucket_key: &str, object_key: &str, writer: &mut (impl AsyncWrite + Unpin), ) -> Result<()>

Download an object and stream it to any async writer (stdout, file, etc.)

Source

pub async fn list_objects(&self, bucket_key: &str) -> Result<Vec<ObjectItem>>

List objects in a bucket

Source

pub async fn delete_object( &self, bucket_key: &str, object_key: &str, ) -> Result<()>

Delete an object from a bucket

Source

pub async fn get_object_details( &self, bucket_key: &str, object_key: &str, ) -> Result<ObjectDetails>

Get detailed metadata for an object without downloading it

Returns extended information including size, SHA1 hash, content type, and timestamps.

Source

pub async fn get_signed_download_url( &self, bucket_key: &str, object_key: &str, minutes_expiration: Option<u32>, ) -> Result<SignedS3DownloadResponse>

Get a signed S3 URL for direct download (bypasses OSS servers)

The signed URL expires in 2 minutes by default.

Source

pub async fn get_signed_upload_url( &self, bucket_key: &str, object_key: &str, parts: Option<u32>, minutes_expiration: Option<u32>, ) -> Result<SignedS3UploadResponse>

Get a signed S3 URL for direct upload (bypasses OSS servers)

The signed URL expires in 2 minutes by default. Returns an upload key that must be used to complete the upload.

Source

pub async fn complete_signed_upload( &self, bucket_key: &str, object_key: &str, upload_key: &str, ) -> Result<ObjectInfo>

Complete an S3 signed upload

Source§

impl OssClient

Source

pub fn new(config: Config, auth: AuthClient) -> Self

Create a new OSS client

Source

pub fn new_with_http_config( config: Config, auth: AuthClient, http_config: HttpClientConfig, ) -> Self

Create a new OSS client with custom HTTP config

Source

pub fn get_urn(&self, bucket_key: &str, object_key: &str) -> String

Generate a base64-encoded URN for an object

Trait Implementations§

Source§

impl Clone for OssClient

Source§

fn clone(&self) -> OssClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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