tencent-qcloud-cos-rs

Crates.iotencent-qcloud-cos-rs
lib.rstencent-qcloud-cos-rs
version0.1.0
sourcesrc
created_at2023-03-04 10:05:35.397929
updated_at2023-03-04 10:05:35.397929
descriptionprovide basic interface encapsulation of Tencent Cloud Object Storage (cos)
homepage
repositoryhttps://github.com/simman/tencent-qcloud-cos-rs
max_upload_size
id800525
size106,813
SimMan (simman)

documentation

README

Crates.io qcos

异步版本 async/await

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

How to use

use tencent_qcloud_cos_rs::acl::{AclHeader, ObjectAcl};
use tencent_qcloud_cos_rs::client::Client;
use tencent_qcloud_cos_rs::objects::{mime, ErrNo, Objects};

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

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

更多的例子请参考examples

Installation

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

[dependencies]
tencent-qcloud-cos-rs = "0.1.0"

Other

fork base: https://github.com/bujnlc8/qcos

Commit count: 24

cargo fmt