add remove http:// or https://
This commit is contained in:
@@ -175,7 +175,8 @@ fn main() -> XResult<()> {
|
|||||||
print_message(MessageType::ERROR, &format!("Error in open file: {}, at item index: {}", e, item_index));
|
print_message(MessageType::ERROR, &format!("Error in open file: {}, at item index: {}", e, item_index));
|
||||||
fs::remove_file(temp_zip_file).ok();
|
fs::remove_file(temp_zip_file).ok();
|
||||||
fs::remove_file(temp_pgp_file).ok();
|
fs::remove_file(temp_pgp_file).ok();
|
||||||
continue;},
|
continue;
|
||||||
|
},
|
||||||
Ok(file_temp_pgp_file) => file_temp_pgp_file,
|
Ok(file_temp_pgp_file) => file_temp_pgp_file,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,9 @@ 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 {
|
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);
|
let mut signed_url = String::with_capacity(1024);
|
||||||
signed_url.push_str(if is_https { "https://" } else { "http://" });
|
signed_url.push_str(if is_https { "https://" } else { "http://" });
|
||||||
signed_url.push_str(&format!("{}.{}/{}", bucket_name, self.endpoint, key));
|
|
||||||
|
let endpoint = &remove_endpoint_http_or_s(self.endpoint);
|
||||||
|
signed_url.push_str(&format!("{}.{}/{}", bucket_name, endpoint, key));
|
||||||
|
|
||||||
let current_secs = get_current_secs();
|
let current_secs = get_current_secs();
|
||||||
let expire_secs = current_secs + expire_in_seconds;
|
let expire_secs = current_secs + expire_in_seconds;
|
||||||
@@ -96,6 +98,16 @@ impl<'a> OSSClient<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn remove_endpoint_http_or_s(endpoint: &str) -> String {
|
||||||
|
let mut endpoint = endpoint.to_owned();
|
||||||
|
if endpoint.starts_with("http://") {
|
||||||
|
endpoint = endpoint.chars().skip("http://".chars().count()).collect::<String>();
|
||||||
|
} else if endpoint.starts_with("https://") {
|
||||||
|
endpoint = endpoint.chars().skip("https://".chars().count()).collect::<String>();
|
||||||
|
}
|
||||||
|
endpoint
|
||||||
|
}
|
||||||
|
|
||||||
fn get_to_be_signed(verb: &str, expire_secs: u64, bucket_name: &str, key: &str) -> String {
|
fn get_to_be_signed(verb: &str, expire_secs: u64, bucket_name: &str, key: &str) -> String {
|
||||||
let mut to_be_signed = String::with_capacity(512);
|
let mut to_be_signed = String::with_capacity(512);
|
||||||
to_be_signed.push_str(verb);
|
to_be_signed.push_str(verb);
|
||||||
|
|||||||
Reference in New Issue
Block a user