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,
is_all: bool,
) -> Result<Vec<ObjectMeta>, ObsError>
pub async fn list( &self, prefix: &str, is_all: bool, ) -> Result<Vec<ObjectMeta>, ObsError>
列举指定前缀开头的所有对象元数据,方法内部会构造http请求:
GET / HTTP/1.1
Host: bucketname.obs.cn-north-4.myhuaweicloud.com
Date: date
Authorization: authorization§参数
prefix - 对象名前缀
is_all - 是否列举所有满足prefix的对象,true表示分页查询所有对象,false表示只查询第一页(最多1000个)
Sourcepub async fn upload_object(
&self,
obj_key: &str,
data: Vec<u8>,
) -> Result<(), ObsError>
pub async fn upload_object( &self, obj_key: &str, data: Vec<u8>, ) -> Result<(), ObsError>
上传对象
方法内部构建请求
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<(), ObsError>
pub async fn upload_file( &self, obj_key: &str, file_path: &str, ) -> Result<(), ObsError>
上传文件
Sourcepub async fn download_object(&self, obj_key: &str) -> Result<Vec<u8>, ObsError>
pub async fn download_object(&self, obj_key: &str) -> Result<Vec<u8>, ObsError>
下载对象,方法内部会构造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<(), ObsError>
pub async fn download_file( &self, obj_key: &str, file_path: &str, overwrite: bool, ) -> Result<(), ObsError>
Sourcepub async fn download_files(
&self,
files: Vec<(&str, &str, bool)>,
) -> Vec<Result<(), ObsError>>
pub async fn download_files( &self, files: Vec<(&str, &str, bool)>, ) -> Vec<Result<(), ObsError>>
pub fn url_sign(&self, url_str: &str) -> Result<String, ObsError>
Auto Trait Implementations§
impl Freeze for ObsClient
impl RefUnwindSafe for ObsClient
impl Send for ObsClient
impl Sync for ObsClient
impl Unpin for ObsClient
impl UnsafeUnpin 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