This commit is contained in:
2019-12-27 01:04:12 +08:00
parent 51be27f775
commit 0a7a0deedb

View File

@@ -15,6 +15,13 @@ use reqwest::{
};
use rust_util::*;
/// iff!(condition, result_when_true, result_when_false)
macro_rules! iff {
($c:expr, $t:expr, $f:expr) => {
if $c { $t } else { $f }
};
}
pub const OSS_VERB_GET: &str = "GET";
pub const OSS_VERB_PUT: &str = "PUT";
pub const OSS_VERB_DELETE: &str = "DELETE";
@@ -83,7 +90,7 @@ impl<'a> OSSClient<'a> {
pub fn generate_signed_url(&self, verb: &str, bucket_name: &str, key: &str, expire_in_seconds: u64, is_https: bool) -> String {
let mut signed_url = String::with_capacity(1024);
signed_url.push_str(if is_https { "https://" } else { "http://" });
signed_url.push_str(iff!(is_https, "https://", "http://"));
signed_url.push_str(&format!("{}.{}/{}", bucket_name, self.endpoint, key));
let current_secs = get_current_secs();