add put
This commit is contained in:
@@ -11,6 +11,7 @@ use crypto::{
|
||||
};
|
||||
|
||||
pub const OSS_VERB_GET: &str = "GET";
|
||||
pub const OSS_VERB_PUT: &str = "PUT";
|
||||
|
||||
// https://help.aliyun.com/document_detail/31952.html
|
||||
pub struct OSSClient<'a> {
|
||||
@@ -28,6 +29,10 @@ impl<'a> OSSClient<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_signed_put_url(&self, bucket_name: &str, key: &str, expire_in_seconds: u64) -> String {
|
||||
self.generate_signed_url(OSS_VERB_PUT, bucket_name, key, expire_in_seconds, true)
|
||||
}
|
||||
|
||||
pub fn generate_signed_get_url(&self, bucket_name: &str, key: &str, expire_in_seconds: u64) -> String {
|
||||
self.generate_signed_url(OSS_VERB_GET, bucket_name, key, expire_in_seconds, true)
|
||||
}
|
||||
@@ -51,6 +56,7 @@ impl<'a> OSSClient<'a> {
|
||||
signed_url.push_str("&Signature=");
|
||||
|
||||
let to_be_signed = get_to_be_signed(verb, expire_secs, bucket_name, key);
|
||||
println!("{}", &to_be_signed);
|
||||
let signature = to_base64(calc_hmac_sha1(self.access_key_secret.as_bytes(), to_be_signed.as_bytes()));
|
||||
signed_url.push_str(&urlencoding::encode(signature.as_str()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user