feat: v0.3.3, add put_body
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
[package]
|
||||
name = "oss"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||
edition = "2018"
|
||||
description = "Simple Alibaba Cloud OSS Client in Rust"
|
||||
license = "MIT"
|
||||
readme="README.md"
|
||||
readme = "README.md"
|
||||
repository = "https://git.hatter.ink/hatter/simple-oss"
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ repository = "https://git.hatter.ink/hatter/simple-oss"
|
||||
rust-crypto = "0.2.36"
|
||||
urlencoding = "1.0.0"
|
||||
base64 = "0.11.0"
|
||||
reqwest = "0.12.0"
|
||||
rust_util="0.6.3"
|
||||
reqwest = { version = "0.12.0", features = ["stream"] }
|
||||
rust_util = "0.6.3"
|
||||
json = "0.12.0"
|
||||
tokio-util = "0.7.11"
|
||||
|
||||
18
src/lib.rs
18
src/lib.rs
@@ -6,7 +6,7 @@ use crypto::{
|
||||
mac::{Mac, MacResult},
|
||||
sha1::Sha1,
|
||||
};
|
||||
use reqwest::Response;
|
||||
use reqwest::{Body, Response};
|
||||
use rust_util::{new_box_ioerror, util_time::get_current_secs, XResult};
|
||||
use std::{
|
||||
env,
|
||||
@@ -109,6 +109,22 @@ impl OSSClient {
|
||||
Ok(client.put(&put_url).body(v).send().await?)
|
||||
}
|
||||
|
||||
/// Put body to OSS
|
||||
// tokio = { version = "1.0", features = ["full"] }
|
||||
// use tokio::fs::File;
|
||||
// tokio-util = { version = "0.6", features = ["codec"] }
|
||||
// use tokio_util::codec::{BytesCodec, FramedRead};
|
||||
// fn file_to_body(file: File) -> Body {
|
||||
// let stream = FramedRead::new(file, BytesCodec::new());
|
||||
// let body = Body::wrap_stream(stream);
|
||||
// body
|
||||
// }
|
||||
pub async fn put_body(&self, bucket_name: &str, key: &str, expire_in_seconds: u64, body: Body) -> XResult<Response> {
|
||||
let put_url = self.generate_signed_put_url(bucket_name, key, expire_in_seconds);
|
||||
let client = reqwest::Client::new();
|
||||
Ok(client.put(&put_url).body(body).send().await?)
|
||||
}
|
||||
|
||||
pub async fn delete_file(&self, bucket_name: &str, key: &str) -> XResult<Response> {
|
||||
let delete_url = self.generate_signed_delete_url(bucket_name, key, 30_u64);
|
||||
let client = reqwest::Client::new();
|
||||
|
||||
Reference in New Issue
Block a user