add timestamp to save imgs
This commit is contained in:
parent
9983d0f14a
commit
844e2c1f8c
@ -1,5 +1,6 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
|
use chrono::Utc;
|
||||||
use rocket::{
|
use rocket::{
|
||||||
form::Form,
|
form::Form,
|
||||||
fs::TempFile,
|
fs::TempFile,
|
||||||
@ -148,7 +149,11 @@ async fn new_thirty(
|
|||||||
return Flash::error(Redirect::to("/ergo"), "Es werden nur JPG Bilder akzeptiert");
|
return Flash::error(Redirect::to("/ergo"), "Es werden nur JPG Bilder akzeptiert");
|
||||||
};
|
};
|
||||||
let base_dir = env::current_dir().unwrap();
|
let base_dir = env::current_dir().unwrap();
|
||||||
let file_path = base_dir.join(format!("data-ergo/thirty/{}.{extension}", user.name));
|
let file_path = base_dir.join(format!(
|
||||||
|
"data-ergo/thirty/{}_{}.{extension}",
|
||||||
|
user.name,
|
||||||
|
Utc::now()
|
||||||
|
));
|
||||||
if let Err(e) = data.proof.move_copy_to(file_path).await {
|
if let Err(e) = data.proof.move_copy_to(file_path).await {
|
||||||
eprintln!("Failed to persist file: {:?}", e);
|
eprintln!("Failed to persist file: {:?}", e);
|
||||||
}
|
}
|
||||||
@ -185,7 +190,11 @@ async fn new_dozen(
|
|||||||
return Flash::error(Redirect::to("/ergo"), "Es werden nur JPG Bilder akzeptiert");
|
return Flash::error(Redirect::to("/ergo"), "Es werden nur JPG Bilder akzeptiert");
|
||||||
};
|
};
|
||||||
let base_dir = env::current_dir().unwrap();
|
let base_dir = env::current_dir().unwrap();
|
||||||
let file_path = base_dir.join(format!("data-ergo/dozen/{}.{extension}", user.name));
|
let file_path = base_dir.join(format!(
|
||||||
|
"data-ergo/dozen/{}_{}.{extension}",
|
||||||
|
user.name,
|
||||||
|
Utc::now()
|
||||||
|
));
|
||||||
if let Err(e) = data.proof.move_copy_to(file_path).await {
|
if let Err(e) = data.proof.move_copy_to(file_path).await {
|
||||||
eprintln!("Failed to persist file: {:?}", e);
|
eprintln!("Failed to persist file: {:?}", e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user