feature/handle-duplicate-file-name-upload #22

Merged
cameron merged 5 commits from feature/handle-duplicate-file-name-upload into master 2024-01-18 03:40:23 +00:00
Showing only changes of commit bf7fb810de - Show all commits

View File

@@ -169,13 +169,18 @@ async fn upload_image(
warn!("File already exists: {:?}", full_path);
let new_path = format!(
"{:?}_{}.{:?}",
full_path.file_stem(),
Utc::now(),
"{}/{}_{}.{}",
full_path.parent().unwrap().to_str().unwrap(),
full_path.file_stem().unwrap().to_str().unwrap(),
Utc::now().timestamp(),
full_path
.extension()
.expect("Uploaded file should have an extension")
.to_str()
.unwrap()
);
info!("Uploaded: {}", new_path);
let mut file = File::create(new_path).unwrap();
file.write_all(&file_content).unwrap();