Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bujnlc8 committed Aug 23, 2024
1 parent ef6eda9 commit 375415e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use mime;
#[tokio::main]
async fn main() {
let client = Client::new("foo", "bar", "qcloudtest-xxx", "ap-guangzhou");
/// 上传文件
let res = client.put_object(&PathBuf::from("Cargo.toml"), "Cargo.toml", Some(mime::TEXT_PLAIN_UTF_8), None).await;
/// 删除文件
let res = client.delete_object("Cargo.toml").await;
let client = Client::new("secrect-id", "secrect-key", "qcloudtest-xxx", "ap-guangzhou");
/// 上传文件
let res = client.put_object(&PathBuf::from("Cargo.toml"), "Cargo.toml", Some(mime::TEXT_PLAIN_UTF_8), None).await;
/// 删除文件
let res = client.delete_object("Cargo.toml").await;
}
```
*/
Expand Down
24 changes: 20 additions & 4 deletions src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,11 @@ impl client::Client {
match fs::File::create(file_name).await {
Ok(e) => output_file = e,
Err(e) => {
return Response::new(ErrNo::OTHER, format!("创建文件失败: {}", e), Vec::new());
return Response::new(
ErrNo::OTHER,
format!("create file failed: {}", e),
Vec::new(),
);
}
}
let size = size as usize;
Expand Down Expand Up @@ -783,7 +787,11 @@ impl client::Client {
}
}
Err(e) => {
return Response::new(ErrNo::IO, format!("保存文件失败: {}", e), Vec::new());
return Response::new(
ErrNo::IO,
format!("save file failed: {}", e),
Vec::new(),
);
}
}
}
Expand Down Expand Up @@ -829,7 +837,11 @@ impl client::Client {
match fs::File::create(file_name).await {
Ok(e) => output_file = e,
Err(e) => {
return Response::new(ErrNo::OTHER, format!("创建文件失败: {}", e), Vec::new());
return Response::new(
ErrNo::OTHER,
format!("create file failed: {}", e),
Vec::new(),
);
}
}
let size = size as usize;
Expand Down Expand Up @@ -897,7 +909,11 @@ impl client::Client {
}
}
Err(e) => {
return Response::new(ErrNo::IO, format!("保存文件失败: {}", e), Vec::new());
return Response::new(
ErrNo::IO,
format!("save file failed: {}", e),
Vec::new(),
);
}
}
}
Expand Down

0 comments on commit 375415e

Please sign in to comment.