//! bucketç®¡ç† use tencent_qcloud_cos_rs::acl::{AclHeader, BucketAcl}; use tencent_qcloud_cos_rs::bucket::Bucket; use tencent_qcloud_cos_rs::client::Client; use tencent_qcloud_cos_rs::request::ErrNo; use tencent_qcloud_cos_rs::service::Service; #[tokio::main] async fn main() { let client = Client::new( "Your secrect id", "Your secrect key", Some(String::from("Your security token")), "bucket-name", "region", ); // 获å–bukcet列表 let res = client.get_bucket_list().await; if res.error_no == ErrNo::SUCCESS { println!("SUCCESS"); } else { println!("{:?}", res.result); } // åˆ é™¤bucket let res = client.delete_bucket().await; if res.error_no == ErrNo::SUCCESS { println!("SUCCESS"); } else { println!("{:?}", res.result); } // 创建bucket(æ— æƒé™æŽ§åˆ¶), 创建的bucketå³ä¸Šåˆå§‹åŒ–ä¼ å…¥çš„bucket-name let res = client.put_bucket(None).await; if res.error_no == ErrNo::SUCCESS { println!("SUCCESS"); } else { println!("{:?}", res.result); } // 创建bucket(有æƒé™æŽ§åˆ¶) let mut acl = AclHeader::new(); acl.insert_bucket_x_cos_acl(BucketAcl::PRIVATE); let res = client.put_bucket(Some(&acl)).await; if res.error_no == ErrNo::SUCCESS { println!("SUCCESS"); } else { println!("{:?}", res.result); } // 列出key以`abc`开头的文件 let res = client.list_objects("abc", "", "", "", 0).await; if res.error_no == ErrNo::SUCCESS { println!("SUCCESS"); } else { println!("{:?}", res.result); } // 检查bucketçŠ¶æ€ let res = client.check_bucket().await; if res.error_no == ErrNo::SUCCESS { println!("SUCCESS"); } else { println!("{}", res.error_message); } // 写入å˜å‚¨æ¡¶çš„访问控制列表(ACL) let mut acl_header = AclHeader::new(); acl_header.insert_bucket_x_cos_acl(BucketAcl::PRIVATE); let res = client.put_bucket_acl(&acl_header).await; if res.error_no == ErrNo::SUCCESS { println!("SUCCESS"); } else { println!("{}", res.error_message); } }