pub struct ObsClient {
pub endpoint: String,
pub ak: String,
pub sk: String,
pub bucket: String,
}Expand description
华为云OBS客户端
Fields§
§endpoint: String§ak: String§sk: String§bucket: StringImplementations§
Source§impl ObsClient
impl ObsClient
Sourcepub async fn list(
&self,
prefix: &str,
) -> Result<Vec<ObjectMeta>, Box<dyn Error>>
pub async fn list( &self, prefix: &str, ) -> Result<Vec<ObjectMeta>, Box<dyn Error>>
列举指定前缀开头的所有对象元数据,方法内部会构造http请求:
GET / HTTP/1.1
Host: bucketname.obs.cn-north-4.myhuaweicloud.com
Date: date
Authorization: authorizationSourcepub async fn upload_object(
&self,
obj_key: &str,
data: Vec<u8>,
) -> Result<(), Box<dyn Error>>
pub async fn upload_object( &self, obj_key: &str, data: Vec<u8>, ) -> Result<(), Box<dyn Error>>
上传对象
方法内部构建请求
PUT /object01 HTTP/1.1
User-Agent: curl/7.29.0
Host: examplebucket.obs.cn-north-4.myhuaweicloud.com
Accept: */*
Date: WED, 01 Jul 2015 04:11:15 GMT
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:gYqplLq30dEX7GMi2qFWyjdFsyw=
Content-Length: 10240
Expect: 100-continue
[1024 Byte data content]Sourcepub async fn upload_file(
&self,
obj_key: &str,
file_path: &str,
) -> Result<(), Box<dyn Error>>
pub async fn upload_file( &self, obj_key: &str, file_path: &str, ) -> Result<(), Box<dyn Error>>
上传文件
Sourcepub async fn download_object(
&self,
obj_key: &str,
) -> Result<Vec<u8>, Box<dyn Error>>
pub async fn download_object( &self, obj_key: &str, ) -> Result<Vec<u8>, Box<dyn Error>>
下载对象,方法内部会构造http请求:
GET /{obj_key} HTTP/1.1
Host: {bucket}.obs.cn-north-4.myhuaweicloud.com
Date: {date}Sourcepub async fn download_file(
&self,
obj_key: &str,
file_path: &str,
overwrite: bool,
) -> Result<(), Box<dyn Error>>
pub async fn download_file( &self, obj_key: &str, file_path: &str, overwrite: bool, ) -> Result<(), Box<dyn Error>>
pub fn url_sign(&self, url_str: &str) -> Result<String, Box<dyn Error>>
Auto Trait Implementations§
impl Freeze for ObsClient
impl RefUnwindSafe for ObsClient
impl Send for ObsClient
impl Sync for ObsClient
impl Unpin for ObsClient
impl UnwindSafe for ObsClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more