This commit is contained in:
@@ -69,7 +69,7 @@ pub fn generate_key_with_extension(base_key: String, mime_type: String) -> Strin
|
||||
mime::Mime::from_str(&mime_type).unwrap_or(mime::APPLICATION_OCTET_STREAM);
|
||||
if let Some(extensions) = mime_guess::get_mime_extensions_str(mime.as_ref()) {
|
||||
if let Some(extension) = extensions.first() {
|
||||
return format!("{}.{}", base_key, extension);
|
||||
return format!("{}.{}", base_key, extension.to_lowercase());
|
||||
}
|
||||
}
|
||||
base_key
|
||||
@@ -77,7 +77,7 @@ pub fn generate_key_with_extension(base_key: String, mime_type: String) -> Strin
|
||||
|
||||
/// список файлов из S3
|
||||
pub async fn get_s3_filelist(client: &S3Client, bucket: &str) -> Vec<[std::string::String; 2]> {
|
||||
let mut filekeys = Vec::new();
|
||||
let mut filenames = Vec::new();
|
||||
// Запрашиваем список файлов из S3
|
||||
let list_objects_v2 = client.list_objects_v2();
|
||||
let list_response = list_objects_v2
|
||||
@@ -94,14 +94,11 @@ pub async fn get_s3_filelist(client: &S3Client, bucket: &str) -> Vec<[std::strin
|
||||
false => s3_filepath,
|
||||
};
|
||||
let mut parts = filepath.split('/').collect::<Vec<&str>>(); // Explicit type annotation
|
||||
let filename = parts.pop().unwrap();
|
||||
let mut filename_parts = filename.split('.').collect::<Vec<&str>>();
|
||||
let _ext = filename_parts.pop().unwrap_or_default();
|
||||
if let Some(filekey) = filename_parts.pop() {
|
||||
filekeys.push([filekey.to_string(), s3_filepath.to_string()]);
|
||||
if let Some(filename) = parts.pop() {
|
||||
filenames.push([filename.to_string(), s3_filepath.to_string()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
filekeys
|
||||
filenames
|
||||
}
|
||||
Reference in New Issue
Block a user