### Get Object URL Source: https://docs.rs/aliyun-oss-rs/0.1.1/aliyun_oss_rs/index_search= Explains how to generate a pre-signed URL for an OSS object. ```APIDOC ## Get Object URL ### Description Generates a pre-signed URL for an OSS object, which can be used to grant temporary access to the object. ### Method `OssObject::get_object_url()` ### Endpoint N/A (This is an object-level operation) ### Parameters #### Path Parameters - **bucket_name** (string) - Required - The name of the bucket containing the object. - **endpoint** (string) - Required - The OSS endpoint for the bucket. - **object_key** (string) - Required - The key of the object for which to generate the URL. #### Query Parameters - **expiration_date** (OffsetDateTime) - Required - The date and time when the pre-signed URL will expire. ### Request Example ```rust use time::{Duration, OffsetDateTime}; let date = OffsetDateTime::now_utc() + Duration::days(3); let url = object.get_object_url().url(date); ``` ### Response #### Success Response (200) - **url** (string) - The generated pre-signed URL. #### Response Example ```json { "url": "https://your-bucket.oss-cn-zhangjiakou.aliyuncs.com/rust.png?Expires=...&OSSAccessKeyId=...&Signature=..." } ``` ``` -------------------------------- ### Initialization Source: https://docs.rs/aliyun-oss-rs/0.1.1/aliyun_oss_rs/index Demonstrates how to initialize the OssClient with your AccessKey ID and Secret. ```APIDOC ## Initialization ### Description Initializes the `OssClient` which is the entry point for interacting with Alibaba Cloud Object Storage Service (OSS). ### Method N/A (This is a constructor) ### Endpoint N/A ### Parameters None directly for `new()`, but requires credentials. ### Request Example ```rust let client = OssClient::new( "Your AccessKey ID", "Your AccessKey Secret", ); ``` ### Response N/A (Returns an `OssClient` instance) ### Success Response (200) N/A ### Response Example N/A ``` -------------------------------- ### Rust: Initialize and Configure Object Listing Request Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/list_objects.rs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Initializes a new `ListObjects` request for Alibaba Cloud OSS. It sets the request method to GET and configures default query parameters for listing objects, including `list-type=2` and `max-keys=1000`. This is the starting point for building a request to list objects in a bucket. ```rust use crate::common::body_to_bytes; use crate::{ Error, common::{Owner, StorageClass}, error::normal_error, request::{Oss, OssRequest}, }; use http::Method; use serde_derive::Deserialize; use std::cmp; // Returned content #[derive(Debug, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ObjectsList { // Continuation token for subsequent requests pub next_continuation_token: Option, // File list pub contents: Option>, // Group list pub common_prefixes: Option>, } /// Object information #[derive(Debug, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct ObjectInfo { /// Object path pub key: String, /// Last modified time of the object pub last_modified: String, /// The ETag is generated for each object to identify its content. It can be used to check if the object has changed, but it is not recommended to use it as an MD5 checksum for data integrity. pub e_tag: String, #[serde(rename = "Type")] pub type_field: String, /// Size of the object in bytes pub size: u64, /// Storage class of the object pub storage_class: StorageClass, /// Restore status of the object pub restore_info: Option, /// Owner information of the bucket pub owner: Option, } /// Group list #[derive(Debug, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct CommonPrefixes { /// Prefix pub prefix: String, } /// List information of all files in the bucket /// /// By default, retrieves the first 1000 files /// /// See the [Alibaba Cloud documentation](https://help.aliyun.com/document_detail/187544.html) for details pub struct ListObjects { req: OssRequest, } impl ListObjects { pub(super) fn new(oss: Oss) -> Self { let mut req = OssRequest::new(oss, Method::GET); req.insert_query("list-type", "2"); req.insert_query("max-keys", "1000"); ListObjects { req } } ``` -------------------------------- ### Initialization Source: https://docs.rs/aliyun-oss-rs/0.1.1/aliyun_oss_rs/index_search= Demonstrates how to initialize the OssClient with your AccessKey ID and Secret. ```APIDOC ## Initialization ### Description Initialize the `OssClient` with your Alibaba Cloud AccessKey ID and AccessKey Secret to interact with OSS. ### Method `OssClient::new()` ### Parameters - **access_key_id** (string) - Required - Your Alibaba Cloud AccessKey ID. - **access_key_secret** (string) - Required - Your Alibaba Cloud AccessKey Secret. ### Request Example ```rust let client = OssClient::new( "Your AccessKey ID", "Your AccessKey Secret", ); ``` ### Response - **OssClient** - An initialized OssClient instance. ``` -------------------------------- ### GET /object/symlink Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/object/get_symlink.rs_search=u32+-%3E+bool Retrieves the symlink target for a given object. This operation is used to get the target of a symbolic link created in Alibaba Cloud OSS. ```APIDOC ## GET /object/symlink ### Description Retrieves the symlink target for a given object. This operation is used to get the target of a symbolic link created in Alibaba Cloud OSS. ### Method GET ### Endpoint ``` /object/{object_name}?symlink ``` ### Parameters #### Query Parameters - **symlink** (string) - Required - This parameter is used to indicate that the request is to get the symlink target. ### Request Example ```json { "request": "GET /my-bucket/my-symlink?symlink HTTP/1.1" } ``` ### Response #### Success Response (200) - **x-oss-symlink-target** (string) - The target path of the symlink. #### Response Example ```json { "headers": { "x-oss-symlink-target": "my-bucket/my-target-object" } } ``` ``` -------------------------------- ### Initialize OssClient Source: https://docs.rs/aliyun-oss-rs/0.1.1/aliyun_oss_rs/client/struct.OssClient Creates a new OssClient instance for interacting with Alibaba Cloud OSS. Requires Alibaba Cloud AccessKey ID and Secret. ```rust pub fn new(ak_id: &str, ak_secret: &str) -> Self ``` -------------------------------- ### GET /object/tagging Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/object/get_object_tagging.rs_search= Retrieves the tag information associated with an object in Aliyun OSS. This endpoint allows you to get the key-value pairs that have been set as tags for a specific object. ```APIDOC ## GET /object/tagging ### Description Retrieve tag information of an object. ### Method GET ### Endpoint `/object/tagging?tagging=` ### Query Parameters - **tagging** (string) - Required - This parameter is used to specify that you want to retrieve the tagging information for the object. An empty value is expected. ### Response #### Success Response (200) - **TagSet** (object) - Contains the set of tags applied to the object. - **Tag** (array of objects) - A list of tags, where each tag is an object with 'Key' and 'Value' properties. - **Key** (string) - The key of the tag. - **Value** (string) - The value of the tag. #### Response Example ```json { "TagSet": { "Tag": [ { "Key": "environment", "Value": "production" }, { "Key": "owner", "Value": "devops" } ] } } ``` ``` -------------------------------- ### Initialize and Configure OssClient in Rust Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/client/oss_client.rs Demonstrates the creation and configuration of an OssClient using Alibaba Cloud AccessKey ID and Secret. Includes methods for disabling HTTPS and attaching or updating security tokens. The OssClient is the main entry point for interacting with Alibaba Cloud OSS. ```rust use crate::{OssBucket, oss::Oss}; /// Entry point for OSS, implementing APIs to query available regions and list buckets #[derive(Debug, Clone)] pub struct OssClient { pub(crate) oss: Oss, } impl OssClient { /// Initialize an OssClient for subsequent use /// /// - ak_id: Alibaba Cloud AccessKey ID /// - ak_secret: Alibaba Cloud AccessKey Secret /// pub fn new(ak_id: &str, ak_secret: &str) -> Self { OssClient { oss: Oss::new(ak_id, ak_secret), } } /// Disable HTTPS pub fn disable_https(mut self) -> Self { self.oss.set_https(false); self } /// Attach a temporary security token for STS authentication pub fn with_security_token(mut self, token: impl Into) -> Self { self.oss.set_security_token(token); self } /// Update the security token in place for reuse pub fn set_security_token(&mut self, token: impl Into) { self.oss.set_security_token(token); } /// Initialize an OssBucket pub fn bucket(&self, bucket: &str, endpoint: &str) -> OssBucket { OssBucket::new(self.oss.clone(), bucket, endpoint) } /// Query the endpoint information of all regions #[cfg(feature = "async")] pub fn describe_regions(&self) -> DescribeRegions { DescribeRegions::new(self.oss.clone()) } /// List all created buckets #[cfg(feature = "async")] pub fn list_buckets(&self) -> ListBuckets { ListBuckets::new(self.oss.clone()) } } ``` -------------------------------- ### GET /bucket/referer Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/get_bucket_referer.rs Retrieves the referer configuration of a bucket. This endpoint allows you to get the current settings for referer protection on your OSS bucket. ```APIDOC ## GET /bucket/referer ### Description Retrieve the referer configuration of a bucket. This endpoint allows you to get the current settings for referer protection on your OSS bucket. See the [Alibaba Cloud documentation](https://help.aliyun.com/zh/oss/developer-reference/getbucketreferer) for details. ### Method GET ### Endpoint `/bucket/{bucketName}/referer` (Note: The actual endpoint path is inferred from the context and might require the bucket name as a path parameter, though not explicitly shown in the provided code snippet). ### Parameters #### Query Parameters - **referer** (string) - Optional - Used to specify the referer configuration operation. ### Request Example ```json { "example": "No request body is expected for this GET request. Parameters are typically passed via URL." } ``` ### Response #### Success Response (200) - **RefererConfiguration** (object) - An object containing the referer configuration details. This will include allowed referers and disallowed referers. #### Response Example ```json { "example": "{\"RefererConfiguration\": {\"AllowEmpty\": true, \"RefererList\": { \"Referer\": [\"http://example.com/*\", \"http://*.example.net/*\"] }}}" } ``` #### Error Handling - **Error** - If the request fails, an `Error` enum variant will be returned, detailing the nature of the failure (e.g., `OssInvalidResponse`). ``` -------------------------------- ### GET /bucket/worm Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/get_bucket_worm.rs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the WORM (Write Once, Read Many) configuration of a specific bucket. ```APIDOC ## GET /bucket/worm ### Description Retrieves the WORM (Write Once, Read Many) configuration of a specific bucket. This operation allows you to check the WORM settings applied to a bucket, which are crucial for data immutability and compliance requirements. ### Method GET ### Endpoint `/bucket/{bucketName}/worm` ### Parameters #### Path Parameters - **bucketName** (string) - Required - The name of the bucket for which to retrieve the WORM configuration. #### Query Parameters - **worm** (string) - Required - An empty string used to specify the WORM configuration retrieval. ### Request Example ```http GET /my-bucket/worm?worm HTTP/1.1 Host: oss.aliyuncs.com Date: Tue, 01 Aug 2023 09:10:10 GMT Authorization: OSS : ``` ### Response #### Success Response (200 OK) - **BucketWormConfiguration** (object) - Contains the WORM configuration details for the bucket. - **DefaultRetention** (object) - - **Days** (integer) - The number of days for default retention. - **Date** (string) - The date for default retention. - **AllowSameActionForException** (boolean) - Indicates if the same action is allowed for exceptions. #### Response Example ```json { "DefaultRetention": { "Days": 30, "Date": "2023-09-01T00:00:00Z" }, "AllowSameActionForException": false } ``` ``` -------------------------------- ### Initialization Source: https://docs.rs/aliyun-oss-rs/0.1.1/index Demonstrates how to initialize the OssClient with your Alibaba Cloud AccessKey ID and Secret. ```APIDOC ## Initialization ### Description Initializes the `OssClient` with provided Alibaba Cloud AccessKey ID and Secret. ### Method `OssClient::new()` ### Parameters - **access_key_id** (string) - Required - Your Alibaba Cloud AccessKey ID. - **access_key_secret** (string) - Required - Your Alibaba Cloud AccessKey Secret. ### Request Example ```rust let client = OssClient::new( "Your AccessKey ID", "Your AccessKey Secret", ); ``` ### Response Returns an instance of `OssClient`. ``` -------------------------------- ### GET /bucket/location Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/get_bucket_location.rs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the location constraint of an Aliyun OSS bucket. This endpoint allows you to get information about the region where your bucket is hosted. ```APIDOC ## GET /bucket/location ### Description Retrieves bucket location information. See the [Alibaba Cloud documentation](https://help.aliyun.com/zh/oss/developer-reference/getbucketlocation) for details. ### Method GET ### Endpoint /bucket?location ### Query Parameters - **location** (string) - Optional - Used to retrieve the bucket's location. ### Request Example ```json { "bucket_name": "your-bucket-name" } ``` ### Response #### Success Response (200) - **location** (string) - The location constraint of the bucket. #### Response Example ```json { "location": "oss-cn-hangzhou" } ``` ``` -------------------------------- ### Initialize OssClient for Alibaba Cloud OSS Source: https://docs.rs/aliyun-oss-rs/0.1.1/aliyun_oss_rs/struct.OssClient_search= Provides the main entry point for interacting with Alibaba Cloud Object Storage Service (OSS). It allows querying regions and listing buckets. Initialization requires Alibaba Cloud AccessKey ID and Secret. ```rust pub struct OssClient { /* private fields */ } pub fn new(ak_id: &str, ak_secret: &str) -> Self ``` -------------------------------- ### GET /bucket/referer Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/get_bucket_referer.rs_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the referer configuration of a specified bucket. This allows you to manage access control based on referer headers. ```APIDOC ## GET /bucket/referer ### Description Retrieve the referer configuration of a bucket. This operation allows you to configure the allowed referer list and whether to allow all referers. ### Method GET ### Endpoint `/bucket?referer` ### Parameters #### Query Parameters - **referer** (string) - Optional - Used to specify the referer configuration retrieval. An empty value typically triggers the retrieval. ### Request Example ``` GET /my-bucket?referer HTTP/1.1 Host: oss.aliyuncs.com Date: Tue, 29 May 2024 10:00:00 GMT Authorization: OSS : ``` ### Response #### Success Response (200) - **RefererConfiguration** (object) - Contains the referer configuration details. - **AllowEmptyReferer** (boolean) - Indicates whether empty referers are allowed. - **RefererList** (object) - Contains a list of allowed referer strings. - **Referer** (array of strings) - A list of allowed referer patterns. #### Response Example ```json { "AllowEmptyReferer": false, "RefererList": { "Referer": [ "*.example.com", "example.net/*" ] } } ``` ``` -------------------------------- ### OssClient Initialization and Configuration Source: https://docs.rs/aliyun-oss-rs/0.1.1/aliyun_oss_rs/client/struct.OssClient_search= This section details how to initialize and configure the OssClient for interacting with Aliyun OSS. ```APIDOC ## OssClient Entry point for OSS, implementing APIs to query available regions and list buckets. ### `OssClient::new(ak_id: &str, ak_secret: &str) -> Self` **Description**: Initializes an `OssClient` for subsequent use with Alibaba Cloud AccessKey ID and Secret. **Method**: `new` **Parameters**: * `ak_id` (str) - Required - Alibaba Cloud AccessKey ID * `ak_secret` (str) - Required - Alibaba Cloud AccessKey Secret ### `OssClient::disable_https(self) -> Self` **Description**: Disables HTTPS for the client. **Method**: `disable_https` ### `OssClient::with_security_token(self, token: impl Into) -> Self` **Description**: Attaches a temporary security token for STS authentication. **Method**: `with_security_token` **Parameters**: * `token` (String) - Required - Temporary security token for STS authentication. ### `OssClient::set_security_token(&mut self, token: impl Into)` **Description**: Updates the security token in place for reuse. **Method**: `set_security_token` **Parameters**: * `token` (String) - Required - The security token to set. ### `OssClient::bucket(&self, bucket: &str, endpoint: &str) -> OssBucket` **Description**: Initializes an `OssBucket` for a specific bucket and endpoint. **Method**: `bucket` **Parameters**: * `bucket` (str) - Required - The name of the OSS bucket. * `endpoint` (str) - Required - The endpoint of the OSS service. ### `OssClient::describe_regions(&self) -> DescribeRegions` **Description**: Queries the endpoint information of all available regions. **Method**: `describe_regions` ### `OssClient::list_buckets(&self) -> ListBuckets` **Description**: Lists all created buckets associated with the client's credentials. **Method**: `list_buckets` ``` -------------------------------- ### Initialize and Configure OssClient in Rust Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/client/oss_client.rs_search=u32+-%3E+bool Demonstrates how to create an OssClient instance using AccessKey ID and Secret, disable HTTPS, attach or update security tokens, and create a bucket client. This client is the entry point for interacting with Alibaba Cloud OSS APIs. ```Rust use aliyun_oss_rs::client::OssClient; // Initialize the client with AccessKey ID and Secret let client = OssClient::new("your_ak_id", "your_ak_secret"); // Optionally disable HTTPS let client = client.disable_https(); // Attach a security token for STS authentication let client = client.with_security_token("your_security_token"); // Or update the security token in place let mut client_mut = client.clone(); client_mut.set_security_token("new_security_token"); // Create a bucket instance let bucket = client.bucket("your_bucket_name", "your_endpoint"); ``` -------------------------------- ### GET /bucket?worm Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/get_bucket_worm.rs Retrieves the WORM configuration of a bucket. This operation is used to obtain the WORM-related configuration information of a bucket. ```APIDOC ## GET /bucket?worm ### Description Retrieve the WORM configuration of a bucket. This operation is used to obtain the WORM-related configuration information of a bucket. ### Method GET ### Endpoint `/bucket?worm` ### Parameters #### Query Parameters - **worm** (string) - Required - This parameter is used to specify that the request is to get the WORM configuration. ### Request Example ``` GET /your-bucket-name?worm HTTP/1.1 Host: your-oss-endpoint.aliyuncs.com Date: Tue, 28 May 2024 09:00:00 GMT Authorization: OSS yourAccessKeyId:signature ``` ### Response #### Success Response (200) - **BucketWormConfiguration** (object) - Contains the WORM configuration details. - **Enabled** (boolean) - Indicates if WORM is enabled for the bucket. - **RetentionPeriod** (integer) - The retention period in days for the WORM configuration. #### Response Example ```json { "Enabled": true, "RetentionPeriod": 365 } ``` ``` -------------------------------- ### GET /bucket/policy Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/get_bucket_policy.rs_search=std%3A%3Avec Retrieves the bucket policy document for the specified bucket. This operation requires a GET request to the bucket's policy endpoint. ```APIDOC ## GET /bucket/policy ### Description Retrieve the bucket policy document. This endpoint allows you to fetch the access policy associated with an OSS bucket. ### Method GET ### Endpoint `/bucket/policy?policy=` ### Parameters #### Query Parameters - **policy** (string) - Required - This parameter is used to specify the retrieval of the bucket policy. An empty value is typically used. ### Request Example ```json { "example": "(No request body for this operation)" } ``` ### Response #### Success Response (200) - **policy** (string) - The bucket policy document in JSON format. #### Response Example ```json { "example": "{\"Version\": \"1.0\", \"Statement\": [ { \"Action\": \"oss:GetObject\", \"Effect\": \"Allow\", \"Resource\": \"acs:oss:*:*:mybucket/*\", \"Principal\": { \"Service\": \"log.aliyuncs.com\" } } ]}" } ``` ``` -------------------------------- ### List Buckets Source: https://docs.rs/aliyun-oss-rs/0.1.1/aliyun_oss_rs/index Shows how to list buckets associated with your OSS account, with an option to filter by prefix. ```APIDOC ## List Buckets ### Description Lists all buckets accessible by the `OssClient`. Supports filtering results by a specified prefix. ### Method GET (Implied by the send operation on a list request) ### Endpoint N/A (Abstracted by the SDK) ### Parameters #### Query Parameters - **prefix** (string) - Optional - A prefix string to filter the bucket names. ### Request Example ```rust let bucket_list = client.list_buckets().set_prefix("rust").send().await; ``` ### Response #### Success Response (200) - **buckets** (array of OssBucket) - A list of bucket objects. #### Response Example ```json { "buckets": [ { "name": "my-rust-bucket", "creation_date": "2023-01-01T12:00:00Z", "location": "oss-cn-zhangjiakou" } ] } ``` ``` -------------------------------- ### Initialize and Configure OssObject in Rust Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/object/oss_object.rs_search= Demonstrates how to create a new `OssObject` instance, which is fundamental for interacting with Aliyun OSS. It shows the initial creation with an `Oss` client and an object identifier, and how to attach a security token for STS authentication, either during initialization or by updating it later. ```rust use crate::oss::Oss; use aliyun_oss_rs::object::OssObject; // Example of creating an OssObject let oss_client = Oss::builder().build(); // Assuming Oss::builder() is available let object_name = "my-object.txt"; let oss_object = OssObject::new(oss_client.clone(), object_name); // Example of attaching a security token let oss_object_with_token = oss_object.with_security_token("your_sts_token"); // Example of updating the security token in place let mut oss_object_mutable = OssObject::new(oss_client, object_name); os_object_mutable.set_security_token("another_sts_token"); ``` -------------------------------- ### Get Bucket Inventory Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/get_bucket_inventory.rs_search= Retrieves a specific inventory task configuration for an Aliyun OSS bucket. This allows you to get details about a previously configured inventory task. ```APIDOC ## GET /bucket/inventory ### Description Retrieves a specific inventory task configuration for an Aliyun OSS bucket. This allows you to get details about a previously configured inventory task. ### Method GET ### Endpoint `/bucket` with query parameters `inventory=""` and `inventoryId` ### Parameters #### Query Parameters - **inventory** (string) - Required - This parameter must be set to an empty string to indicate an inventory operation. - **inventoryId** (string) - Required - The ID of the inventory task configuration to retrieve. ### Request Example ```rust // Example usage (assuming `oss` is an initialized Oss client) let inventory_id = "my-inventory-id"; let get_inventory_request = aliyun_oss_rs::bucket::GetBucketInventory::new(oss, inventory_id); let inventory_xml = get_inventory_request.send().await?; println!("{}", inventory_xml); ``` ### Response #### Success Response (200) - **String** (string) - The inventory configuration details in XML format. #### Response Example ```xml my-inventory-id true my-bucket inventory/ oss-cn-hangzhou CSV < KMSAliasName>kms:alias/oss Daily All ``` #### Error Response - **Error** - Refer to the aliyun-oss-rs Error enum for details on potential errors (e.g., network issues, invalid credentials, bucket not found). ``` -------------------------------- ### GET /object/{bucketName}/{objectKey} Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/object/get_symlink.rs Retrieves the symlink target for a given object. This endpoint is used to get the target of a symbolic link stored in Aliyun OSS. ```APIDOC ## GET /object/{bucketName}/{objectKey} ### Description Retrieves the symlink target for a given object. This endpoint is used to get the target of a symbolic link stored in Aliyun OSS. ### Method GET ### Endpoint `/object/{bucketName}/{objectKey}?symlink=` ### Parameters #### Query Parameters - **symlink** (string) - Required - This parameter must be set to an empty string to indicate the intention to retrieve symlink information. ### Request Example ```rust // Assuming 'oss' is an initialized Oss client let symlink_target = aliyun_oss_rs::object::get_symlink::GetSymlink::new(oss) .send() .await?; ``` ### Response #### Success Response (200) - **target** (string) - The decoded target path of the symlink. ``` -------------------------------- ### Query Region Information with OssClient Source: https://docs.rs/aliyun-oss-rs/0.1.1/aliyun_oss_rs/client/struct.DescribeRegions_search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to initialize an OssClient and use the describe_regions method to query region information. It shows how to specify a particular region and send the request asynchronously. The output is then printed in a human-readable format. This requires the OssClient and RegionInfo types from the aliyun_oss_rs crate. ```rust let client = OssClient::new("AccessKey ID","AccessKey Secret","oss-cn-beijing.aliyuncs.com"); let regions = client.describe_regions() .set_regions("oss-cn-hangzhou") .send().await; println!("{:#?}", regions); ``` -------------------------------- ### List Buckets Source: https://docs.rs/aliyun-oss-rs/0.1.1/aliyun_oss_rs/index_search= Shows how to list OSS buckets, optionally filtering by a prefix. ```APIDOC ## List Buckets ### Description Retrieves a list of your OSS buckets. You can filter the results by providing a prefix. ### Method `OssClient::list_buckets()` ### Endpoint N/A (This is a client-side operation) ### Query Parameters - **prefix** (string) - Optional - Filters the list of buckets to return only those that begin with the specified prefix. ### Request Example ```rust let bucket_list = client.list_buckets().set_prefix("rust").send().await; ``` ### Response #### Success Response (200) - **bucket_list** (Vec) - A list of OSS buckets. #### Response Example ```json { "buckets": [ { "name": "my-rust-bucket", "creation_date": "2023-10-27T10:00:00Z" } ] } ``` ``` -------------------------------- ### Get Bucket Encryption Configuration (Rust) Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/get_bucket_encryption.rs This Rust code defines the `GetBucketEncryption` struct and its associated `send` method to retrieve the default server-side encryption configuration for an Alibaba Cloud OSS bucket. It handles making the HTTP GET request and parsing the XML response. Dependencies include `serde_xml_rs` for XML deserialization and `http` for request methods. ```rust use crate::{ Error, common::body_to_bytes, error::normal_error, request::{Oss, OssRequest}, }; use http::Method; use super::BucketEncryption; /// Retrieve the default server-side encryption configuration for the bucket. /// /// See the [Alibaba Cloud documentation](https://help.aliyun.com/zh/oss/developer-reference/getbucketencryption) for details. pub struct GetBucketEncryption { req: OssRequest, } impl GetBucketEncryption { pub(super) fn new(oss: Oss) -> Self { let mut req = OssRequest::new(oss, Method::GET); req.insert_query("encryption", ""); GetBucketEncryption { req } } /// Send the request and return the parsed configuration. pub async fn send(self) -> Result { let response = self.req.send_to_oss()?.await?; match response.status() { code if code.is_success() => { let bytes = body_to_bytes(response.into_body()).await?; let encryption: BucketEncryption = serde_xml_rs::from_reader(bytes.as_ref()) .map_err(|_| Error::OssInvalidResponse(Some(bytes)))?; Ok(encryption) } _ => Err(normal_error(response).await), } } } ``` -------------------------------- ### GET /bucket/logging Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/get_bucket_logging.rs_search= Retrieves the bucket logging configuration. This endpoint allows you to check if logging is enabled for a specific bucket and get details about the target bucket and prefix for logs. ```APIDOC ## GET /bucket/logging ### Description Retrieves the bucket logging configuration. This endpoint allows you to check if logging is enabled for a specific bucket and get details about the target bucket and prefix for logs. ### Method GET ### Endpoint /bucket/?logging ### Query Parameters - **logging** (string) - Required - Used to specify the retrieval of bucket logging status. ### Request Example ```rust // Example of how to initialize and send the request (details may vary based on SDK usage) use aliyun_oss_rs::Oss; async fn get_logging_config(oss_client: Oss) -> Result<(), Box> { let client = GetBucketLogging::new(oss_client); let logging_status = client.send().await?; match logging_status { Some(config) => { println!("Logging enabled. Target Bucket: {}, Target Prefix: {}", config.target_bucket, config.target_prefix); }, None => { println!("Logging is not enabled for this bucket."); } } Ok(()) } ``` ### Response #### Success Response (200) - **LoggingEnabled** (object) - Contains the logging configuration if enabled. - **target_bucket** (string) - The bucket where logs are stored. - **target_prefix** (string) - The prefix for the log files. #### Response Example ```json { "LoggingEnabled": { "TargetBucket": "your-log-bucket-name", "TargetPrefix": "logs/" } } ``` #### Error Response - **Error** (object) - Contains details about the error if the request fails. - **Code** (string) - The error code. - **Message** (string) - The error message. - **RequestId** (string) - The request ID for tracing. - **HostId** (string) - The host ID for tracing. ``` -------------------------------- ### Upload a File Source: https://docs.rs/aliyun-oss-rs/0.1.1/aliyun_oss_rs/index_search= Provides instructions on how to upload a file to an OSS bucket. ```APIDOC ## Upload a File ### Description Uploads a local file to a specified object key within an OSS bucket. ### Method `OssObject::put_object()` ### Endpoint N/A (This is an object-level operation) ### Parameters #### Path Parameters - **bucket_name** (string) - Required - The name of the bucket where the object will be uploaded. - **endpoint** (string) - Required - The OSS endpoint for the bucket. - **object_key** (string) - Required - The desired key (name) for the object in the bucket. ### Request Body - **file_path** (string) - Required - The local path to the file to be uploaded. ### Request Example ```rust let bucket = client.bucket("for-rs-test", "oss-cn-zhangjiakou.aliyuncs.com"); let object = bucket.object("rust.png"); let result = object.put_object().send_file("Your File Path").await; ``` ### Response #### Success Response (200) - **result** (UploadResult) - Details of the upload operation. #### Response Example ```json { "etag": "F9A2023E6C2C453E58C276934A56B09A", "last_modified": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Configure Bucket Website Hosting in Rust (aliyun-oss-rs) Source: https://docs.rs/aliyun-oss-rs/0.1.1/aliyun_oss_rs/bucket/struct.PutBucketWebsite Defines the structure `PutBucketWebsite` for configuring static website hosting on an Alibaba Cloud OSS bucket. It allows setting index and error documents, and replacing the raw configuration. The `send` method dispatches the request. ```rust pub struct PutBucketWebsite { /* private fields */ } impl PutBucketWebsite { // Set the index document suffix (for example, `index.html`). pub fn set_index_document(self, suffix: impl ToString) -> Self; // Set the error document key (for example, `error.html`). pub fn set_error_document(self, key: impl ToString) -> Self; // Replace the raw configuration object. pub fn set_configuration(self, config: WebsiteConfiguration) -> Self; // Send the request. pub async fn send(self) -> Result<(), Error>; } ``` -------------------------------- ### Get Bucket Encryption Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/get_bucket_encryption.rs Retrieves the default server-side encryption configuration for a specified bucket. This endpoint allows you to check the current encryption settings applied to your OSS bucket. ```APIDOC ## GET /bucket\?encryption ### Description Retrieve the default server-side encryption configuration for the bucket. ### Method GET ### Endpoint `/bucket?encryption` ### Parameters #### Query Parameters - **encryption** (string) - Required - This parameter must be present to indicate the request is for encryption configuration. ### Request Example ```rust // Example of how to initialize and send the request (assuming `oss` is an initialized Oss client) // let mut client = Oss::new("your-access-key-id", "your-access-key-secret", "your-oss-endpoint"); // let encryption_config = aliyun_oss_rs::bucket::GetBucketEncryption::new(client).send().await?; ``` ### Response #### Success Response (200) - **BucketEncryption** (object) - Contains the server-side encryption configuration details for the bucket. #### Response Example ```json { "ServerSideEncryptionConfiguration": { "Rule": { "ApplyServerSideEncryptionByDefault": { "SSEAlgorithm": "AES256" } } } } ``` #### Error Response - **Error** (object) - Contains details about the error that occurred during the request. ``` -------------------------------- ### Initiate Multipart Upload Source: https://docs.rs/aliyun-oss-rs/0.1.1/aliyun_oss_rs/object/struct.InitUpload This section details the process of initiating a multipart upload for a file to Aliyun OSS. It allows setting various properties like MIME type, ACL, storage class, cache control, content disposition, and metadata. ```APIDOC ## POST /websites/rs_aliyun-oss-rs_0_1_1/object ### Description Initiate a multipart upload for a file to Aliyun OSS. Allows configuration of various upload properties before sending the request. ### Method POST ### Endpoint `/object` (within the context of the aliyun-oss-rs crate) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body This endpoint does not explicitly define a request body in the provided documentation. The configuration is done via chained method calls on the `InitUpload` struct. ### Request Example ```rust use aliyun_oss_rs::object::InitUpload; // Example of building an upload request let upload_request = InitUpload::new() .set_mime("application/json") .set_acl(aliyun_oss_rs::Acl::PublicRead) .set_storage_class(aliyun_oss_rs::StorageClass::Standard) .set_cache_control("no-cache") .set_content_disposition("attachment; filename=\"example.json\"") .forbid_overwrite() .set_meta("custom-key", "custom-value") .set_tagging("environment", "production"); // To send the request: // let result = upload_request.send().await; ``` ### Response #### Success Response (200) - **String** - A string representing the result of the upload initiation, typically an upload ID or a success indicator. #### Response Example ```json { "upload_id": "example-upload-id-12345" } ``` ``` -------------------------------- ### GET /objectMeta Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/object/get_object_meta.rs_search= Retrieves the metadata for a specified object in Aliyun OSS. This includes details like file size, ETag, last modified time, and last access time. ```APIDOC ## GET /objectMeta ### Description Retrieves the metadata for a specified object in Aliyun OSS. This includes details like file size, ETag, last modified time, and last access time. ### Method HEAD ### Endpoint This endpoint is part of the `GetObjectMeta` struct's functionality, which constructs a HEAD request to the Aliyun OSS API. The specific endpoint path is determined by the `OssRequest` configuration. ### Parameters #### Query Parameters - **objectMeta** (string) - Required - An empty string used to signal the retrieval of object metadata. ### Request Example ```rust use aliyun_oss_rs::object::get_object_meta::GetObjectMeta; // Assuming 'oss' is an initialized Oss client let get_object_meta_request = GetObjectMeta::new(oss); ``` ### Response #### Success Response (200) - **content_length** (string) - The size of the object in bytes. - **e_tag** (string) - An identifier for the object's content. - **last_access_time** (string) - Optional. The last time the object was accessed. - **last_modified** (string) - The last time the object was modified. #### Response Example ```json { "content_length": "1024", "e_tag": ""abc123def456ghi789"", "last_access_time": "2023-10-27T10:00:00Z", "last_modified": "2023-10-26T08:00:00Z" } ``` #### Error Response - **Error** - An error structure containing details about the failure, which could be an `OssInvalidError` or `OssError`. ```rust match result { Ok(meta) => println!("Object meta: {:?}", meta), Err(e) => eprintln!("Error retrieving object meta: {:?}", e), } ``` ``` -------------------------------- ### GET /bucket/lifecycle Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/get_bucket_lifecycle.rs Retrieve the lifecycle configuration of a bucket. This endpoint allows you to fetch the current lifecycle rules applied to a specific bucket in Aliyun OSS. ```APIDOC ## GET /bucket/lifecycle ### Description Retrieve the lifecycle configuration of a bucket. This endpoint allows you to fetch the current lifecycle rules applied to a specific bucket in Aliyun OSS. See the [Alibaba Cloud documentation](https://help.aliyun.com/zh/oss/developer-reference/getbucketlifecycle) for details. ### Method GET ### Endpoint `/bucket/lifecycle?lifecycle=` ### Parameters #### Query Parameters - **lifecycle** (string) - Required - This parameter is used to specify that you want to retrieve the lifecycle configuration. It should be an empty string. ### Request Example ```json { "example": "Not applicable for this request, as it uses query parameters." } ``` ### Response #### Success Response (200) - **lifecycle_xml** (string) - The lifecycle configuration of the bucket in XML format. #### Response Example ```xml DeleteOldObject logs/ Enabled 30 ``` ``` -------------------------------- ### List Objects in a Bucket Source: https://docs.rs/aliyun-oss-rs/0.1.1/aliyun_oss_rs/index_search= Demonstrates how to list objects within a specified OSS bucket. ```APIDOC ## List Objects in a Bucket ### Description Lists all objects within a specified OSS bucket. This operation allows you to see the contents of your buckets. ### Method `OssBucket::list_objects()` ### Endpoint N/A (This is a bucket-level operation) ### Parameters #### Path Parameters - **bucket_name** (string) - Required - The name of the bucket to list objects from. - **endpoint** (string) - Required - The OSS endpoint for the bucket (e.g., `oss-cn-zhangjiakou.aliyuncs.com`). ### Request Example ```rust let bucket = client.bucket("for-rs-test", "oss-cn-zhangjiakou.aliyuncs.com"); let files = bucket.list_objects().send().await; ``` ### Response #### Success Response (200) - **files** (Vec) - A list of objects within the bucket. #### Response Example ```json { "objects": [ { "key": "rust.png", "size": 1024, "last_modified": "2023-10-27T10:00:00Z" } ] } ``` ``` -------------------------------- ### Get Bucket Lifecycle Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/get_bucket_lifecycle.rs_search=std%3A%3Avec Retrieves the lifecycle configuration of an Alibaba Cloud OSS bucket. This endpoint allows you to get the XML document detailing the bucket's lifecycle rules. ```APIDOC ## GET /bucket/lifecycle ### Description Retrieve the lifecycle configuration of a bucket. This operation returns the lifecycle configuration of the specified bucket. To use this operation, you must have read access to the bucket. ### Method GET ### Endpoint `/bucket/lifecycle` ### Parameters #### Query Parameters - **lifecycle** (string) - Required - Used to specify the retrieval of the lifecycle configuration. ### Request Example ```json { "example": "GET /bucket?lifecycle\nHost: example.oss.aliyuncs.com\nDate: Tue, 20 Dec 2022 04:03:37 GMT\nAuthorization: OSS example:V93/llUpQpX40s9C+f/r2U4H7D0=" } ``` ### Response #### Success Response (200) - **lifecycle_xml** (string) - The XML document containing the bucket's lifecycle configuration. #### Response Example ```xml DeleteOldObject logs/ Enabled 30 ``` ``` -------------------------------- ### Configure Aliyun OSS Bucket (Rust Test) Source: https://docs.rs/aliyun-oss-rs/0.1.1/src/aliyun_oss_rs/bucket/oss_bucket.rs_search=std%3A%3Avec Demonstrates the configuration of an Aliyun OSS bucket, including setting a security token and custom domain. This is a synchronous test case. ```Rust #[test] fn test_bucket_creation_and_custom_domain() { let bucket = OssBucket::new( Oss::new("id", "secret"), "my-bucket", "oss-cn-example.aliyuncs.com", ) .with_security_token("token") .set_custom_domain("cdn.example.com", false); assert_eq!(bucket.oss.bucket.as_deref(), Some("my-bucket")); assert_eq!(bucket.oss.endpoint.as_ref(), "oss-cn-example.aliyuncs.com"); assert_eq!(bucket.oss.custom_domain.as_deref(), Some("cdn.example.com")); assert!(!bucket.oss.enable_https); assert_eq!(bucket.oss.security_token.as_deref(), Some("token")); let mut bucket = bucket.clone(); bucket.set_security_token("token2"); assert_eq!(bucket.oss.security_token.as_deref(), Some("token2")); } ```