Skip to content

Commit

Permalink
Fix post policy domain generation
Browse files Browse the repository at this point in the history
  • Loading branch information
riquito committed Jan 1, 2024
1 parent be1be7b commit d9d621e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions svanill-vault-server/src/file_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,18 @@ impl FileServer {
// https://s3.eu-central-1.amazonaws.com/some-bucketname/...&X-Amz-Algorithm...
// to https://some-bucketname.s3.eu-central-1.amazonaws.com
// Protocol could be http/https, domain could also be an ip with port, etc...
// There must be an sdk function to get it, but I can't find it.
let v: Vec<&str> = retrieve_url.splitn(4, '/').collect();

if let [protocol, _, domain, _] = &v[..] {
let upload_url = [protocol, "//", &self.bucket, ".", domain].join("");
if let [protocol, _, mut domain, _] = &v[..] {
let final_domain: String;

if !domain.starts_with(&self.bucket) {
final_domain = format!("{}.{}", &self.bucket, &domain);
domain = &final_domain;
}

let upload_url = [protocol, "//", domain].join("");
Ok((upload_url, retrieve_url.to_owned(), form_data))
} else {
Err(FileServerError::PolicyDataError(
Expand Down

0 comments on commit d9d621e

Please sign in to comment.