Expand description
Alibaba Cloud Object Storage Service (OSS) is a massive, secure, low-cost, and reliable cloud storage service provided by Alibaba Cloud.
Designed with simplicity and practicality in mind, it uses a chained structure (OssClient -> OssBucket -> OssObject -> Operation) to implement common APIs. Unsupported APIs will be added gradually.
§Notes
- Versioning is not supported yet; if your bucket has versioning enabled, functionality and data may be incomplete
- Server-side encryption is currently unsupported
- Most methods do not validate parameter characters. You must strictly follow OSS requirements or local or remote errors may occur
§Usage
§Initialization
ⓘ
let client = OssClient::new(
"Your AccessKey ID",
"Your AccessKey Secret",
);
§List buckets
ⓘ
let bucket_list = client.list_buckets().set_prefix("rust").send().await;
§List objects in a bucket
ⓘ
let bucket = client.bucket("for-rs-test","oss-cn-zhangjiakou.aliyuncs.com");
let files = bucket.list_objects().send().await;
§Upload a file
ⓘ
let object = bucket.object("rust.png");
let result = object.put_object().send_file("Your File Path").await;
§Get an object’s URL
ⓘ
use time::{Duration, OffsetDateTime};
let date = OffsetDateTime::now_utc() + Duration::days(3);
let url = object.get_object_url().url(date);
Modules§
- bucket
- A bucket is a container for storing objects; every object must belong to a bucket.
- client
- Basic service including AccessKey and endpoint information
- common
- Common data definitions
- object
- An object is the basic unit for storing data in OSS, composed of metadata, user data, and a key that uniquely identifies it within a bucket.
Structs§
- OssBucket
- OSS bucket implementing APIs for creating buckets, retrieving bucket information, listing objects, and more
- OssClient
- Entry point for OSS, implementing APIs to query available regions and list buckets
- OssObject
- OSS object implementing APIs such as uploading and deleting files