#cos #tencent-cloud #tengxunyun #object-storage

rust-qcos

provide basic interface encapsulation of Tencent Cloud Object Storage (cos)

2 releases

0.0.3 Nov 27, 2024
0.0.2 Apr 23, 2024

#3 in #tencent-cloud

Download history 1/week @ 2024-08-28 4/week @ 2024-09-18 8/week @ 2024-09-25 7/week @ 2024-10-02 1/week @ 2024-10-09 2/week @ 2024-10-16 20/week @ 2024-10-23 8/week @ 2024-11-13 7/week @ 2024-11-20 181/week @ 2024-11-27 10/week @ 2024-12-04 6/week @ 2024-12-11

209 downloads per month

MIT license

62KB
1.5K SLoC

qcos

异步版本 async/await

本包提供腾讯云对象存储(cos) 基本的操作,包括bucket创建及删除,对象的上传(支持分块传输)、下载、删除等。后续有时间会补充其他接口的实现。

How to use

use rust-qcos::acl::{AclHeader, ObjectAcl};
use rust-qcos::client::Client;
use rust-qcos::objects::{mime, ErrNo, Objects};

#[tokio::main]
async fn main() {
    let client = Client::new(
        "Your secrect id",
        "Your secrect key",
        "bucket name",
        "region",
    );
    let mut acl_header = AclHeader::new();
    acl_header.insert_object_x_cos_acl(ObjectAcl::PublicRead);
    let data = std::fs::read("test.png").unwrap();
    let res = client.put_object(mime::IMAGE_PNG, "test.png", data, Some(&acl_header)).await;
    if res.error_no == ErrNo::SUCCESS {
        println!("success");
    } else {
        println!("{}", res.error_message);
    }
}

如果操作成功,会打印出success, 否则会打印出失败原因。

Installation

insert into your project's cargo.toml block next line

[dependencies]
rust-qcos = "0.0.2"

Dependencies

~14–30MB
~497K SLoC