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>, ObsError>
pub async fn list(&self, prefix: &str) -> Result<Vec<ObjectMeta>, ObsError>
列举指定前缀开头的所有对象元数据,方法内部会构造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<(), 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>
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