{"id":19666559,"url":"https://github.com/tu6ge/oss-rs","last_synced_at":"2025-11-12T21:34:07.873Z","repository":{"id":40390168,"uuid":"492487428","full_name":"tu6ge/oss-rs","owner":"tu6ge","description":"一个阿里云 OSS 的 rust 客户端","archived":false,"fork":false,"pushed_at":"2025-09-06T15:10:54.000Z","size":1610,"stargazers_count":44,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-12T21:33:39.343Z","etag":null,"topics":["aliyun","aliyun-oss","aliyun-rust","aliyun-sdk","rust-sdk"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tu6ge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-15T12:57:08.000Z","updated_at":"2025-09-06T15:08:48.000Z","dependencies_parsed_at":"2023-02-10T08:30:52.319Z","dependency_job_id":"834f6ea1-657f-49be-8641-f1e30d4179fb","html_url":"https://github.com/tu6ge/oss-rs","commit_stats":{"total_commits":627,"total_committers":3,"mean_commits":209.0,"dds":0.3317384370015949,"last_synced_commit":"2067fc019ae37ca0f8930c284ce6587f36a34918"},"previous_names":[],"tags_count":68,"template":false,"template_full_name":null,"purl":"pkg:github/tu6ge/oss-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tu6ge%2Foss-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tu6ge%2Foss-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tu6ge%2Foss-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tu6ge%2Foss-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tu6ge","download_url":"https://codeload.github.com/tu6ge/oss-rs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tu6ge%2Foss-rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284115869,"owners_count":26949957,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-12T02:00:06.336Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aliyun","aliyun-oss","aliyun-rust","aliyun-sdk","rust-sdk"],"created_at":"2024-11-11T16:28:07.165Z","updated_at":"2025-11-12T21:34:07.856Z","avatar_url":"https://github.com/tu6ge.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aliyun_oss_client 打算采用一种全新的方式来实现\n\n**巨大更新，之前使用过的，慎重升级 0.13**\n\n目前的实现，代码将大大简化，api 接口也更加起清晰，使用了有限的 rust 语言特性，所以接口更加统一，\n大大减少了外部依赖\n\n\u003e 使用本 lib 创建的 oss 命令行工具：[tu6ge/oss-cli](https://github.com/tu6ge/oss-cli)，也算是本库的一个演示项目\n\n详细使用案例如下：\n\n1. 基本操作\n\n```rust\nuse aliyun_oss_client::{types::ObjectQuery, Client, EndPoint};\n\nasync fn run() -\u003e Result\u003c(), aliyun_oss_client::Error\u003e {\n    let client = Client::from_env()?;\n\n    // 获取 buckets 列表\n    let buckets = client.get_buckets(\u0026EndPoint::CN_QINGDAO).await?;\n\n    // 获取某一个 bucket 的文件列表\n    let objects = buckets[0]\n        .clone()\n        //.object_query(ObjctQuery::new())\n        .get_objects(\u0026client).await?;\n\n    // 获取第二页数据\n    let second_objects = objects.next_list(\u0026client).await?;\n\n    // 获取文件的详细信息\n    let obj_info = objects[0].get_info(\u0026client).await?;\n\n    // 上传文件\n    let res = Object::new(\"abc2.txt\")\n        .content(\"aaab\".into())\n        .content_type(\"text/plain;charset=utf-8\")\n        .upload(\u0026client)\n        .await?;\n\n    // 使用文件句柄上传文件\n    let mut f = File::open(\"example_file.txt\").unwrap();\n    let info = Object::new(\"abc_file.txt\")\n        .file(\u0026mut f)?\n        .content_type(\"text/plain;charset=utf-8\")\n        .upload(\u0026client)\n        .await?;\n\n    // 使用文件路径上传文件\n    let info = Object::new(\"abc_file.txt\")\n        .file_path(\"example_file.txt\")?\n        .content_type(\"text/plain;charset=utf-8\")\n        .upload(\u0026client)\n        .await?;\n\n    // 下载文件内容\n    let content = object.download(\u0026client).await?;\n\n    // 复制文件\n    let res = Object::new(\"new_file.txt\")\n        .copy_source(\"/bucket_name/source_file.txt\")\n        .content_type(\"text/plain;charset=utf-8\")\n        .copy(\u0026client)\n        .await?;\n\n    // 分片上传（大文件）\n    let result = PartsUpload::new(\"myvideo23.mov\")\n        .file_path(\"./video.mov\".into())\n        .upload(\u0026client)\n        .await;\n\n    // 删除文件\n    let result = Object::new(\"abc.txt\")\n        .delete(\u0026client)\n        .await;\n\n    Ok(())\n}\n```\n\n2. 导出 bucket 到自定义类型\n\n```rust\n#[derive(Debug, Deserialize)]\nstruct MyBucket {\n    Comment: String,\n    CreationDate: String,\n    ExtranetEndpoint: EndPoint,\n    IntranetEndpoint: String,\n    Location: String,\n    Name: String,\n    Region: String,\n    StorageClass: String,\n}\n\nlet list: Vec\u003cMyBucket\u003e = client.export_buckets(\u0026EndPoint::CN_QINGDAO).await?;\n```\n\n3. 导出 bucket 详细信息到自定义类型\n\n```rust\n#[derive(Debug, Deserialize)]\nstruct MyBucketInfo {\n    Name: String,\n}\nlet res: MyBucketInfo = buckets[0].export_info(\u0026client).await?;\n```\n\n4. 导出 object 列表到自定义\n\n```rust\nlet condition = {\n    let mut map = ObjectQuery::new();\n    map.insert(ObjectQuery::MAX_KEYS, \"5\");\n    map\n};\n\n#[derive(Debug, Deserialize)]\nstruct MyObject {\n    Key: String,\n}\n\nlet (list, next_token): (Vec\u003cMyObject\u003e, _) =\n    buckets[0].export_objects(\u0026condition, \u0026client).await?;\n```\n\n# RFC\n\nget Buckets\n\n```rust\nstruct Client {\n   key: String,\n   secret: String,\n}\n\nimpl Client {\n    async fn get_buckets(\u0026self, endpoint: EndPoint) -\u003e Vec\u003cBucket\u003e {\n        todo!()\n    }\n\n    // 导出到自定义的类型\n    pub async fn export_buckets\u003cB: DeserializeOwned\u003e(\n        \u0026self,\n        endpoint: \u0026EndPoint,\n    ) -\u003e Result\u003cVec\u003cB\u003e, OssError\u003e {\n        //...\n    }\n}\n```\n\nget bucket info;\n\n```rust\nstruct Bucket {\n    name: String,\n    endpoint: EndPoint,\n}\nimpl Bucket{\n    async fn get_info(\u0026self, client: \u0026Client) -\u003e BucketInfo {\n        todo!()\n    }\n\n    // 导出到自定义的类型\n    pub async fn export_info\u003cB: DeserializeOwned\u003e(\u0026self, client: \u0026Client) -\u003e Result\u003cB, OssError\u003e {\n        //...\n    }\n\n    async fn get_object(\u0026self, client: \u0026Client) -\u003e Vec\u003cObject\u003e {\n        todo!()\n    }\n\n    // 导出到自定义的类型\n    pub async fn export_objects\u003cObj: DeserializeOwned\u003e(\n        \u0026self,\n        query: \u0026ObjectQuery,\n        client: \u0026Client,\n    ) -\u003e Result\u003c(Vec\u003cObj\u003e, NextContinuationToken), OssError\u003e {\n        //...\n    }\n}\n```\n\nget object info\n\n```rust\nstruct Object {\n    bucket: Bucket,\n    path: ObjectPath,\n}\nimpl Object {\n    async fn get_info(\u0026self, client: \u0026Client) -\u003e ObjectInfo {\n        todo!()\n    }\n\n    async fn upload(\u0026self, client: \u0026Client, content: Vec\u003cu8\u003e) -\u003e Result\u003c(), Error\u003e{\n        todo!()\n    }\n    async fn download(\u0026self, client: \u0026Client) -\u003e Result\u003cVec\u003cu8\u003e, Error\u003e{\n        todo!()\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftu6ge%2Foss-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftu6ge%2Foss-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftu6ge%2Foss-rs/lists"}