From 3f3681b037139224399b074a4f804dc811def65d Mon Sep 17 00:00:00 2001 From: veypi Date: Wed, 3 Jan 2024 07:58:56 +0800 Subject: [PATCH] update --- oab/src/api/upload.rs | 10 +++++----- oab/src/cfg.rs | 1 - oaweb/yarn.lock | 8 ++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/oab/src/api/upload.rs b/oab/src/api/upload.rs index 1a4b0dd..87c51fd 100644 --- a/oab/src/api/upload.rs +++ b/oab/src/api/upload.rs @@ -35,8 +35,8 @@ async fn save_files( dir = "tmp".to_string(); } let mut res: Vec = Vec::new(); - form.files.into_iter().for_each(|v| { - let fname = v.file_name.unwrap_or("unknown".to_string()); + for v in form.files.into_iter() { + let fname = v.file_name.clone().unwrap_or("unknown".to_string()); let root = Path::new(&stat.media_path).join(dir.clone()); if !root.exists() { match fs::create_dir_all(root.clone()) { @@ -52,8 +52,8 @@ async fn save_files( t.id, fname ); - info!("saving to {temp_file}"); - match v.file.persist(temp_file) { + info!("saving {:?} to {temp_file}", v.file.path().to_str()); + match fs::copy(v.file.path(), &temp_file) { Ok(p) => { info!("{:#?}", p); res.push(format!("/media/{}/{}.{}", dir, t.id, fname)) @@ -62,7 +62,7 @@ async fn save_files( warn!("{}", e); } }; - }); + } Ok(web::Json(res)) } diff --git a/oab/src/cfg.rs b/oab/src/cfg.rs index e8fa1fe..96a1723 100644 --- a/oab/src/cfg.rs +++ b/oab/src/cfg.rs @@ -281,7 +281,6 @@ pub fn init_log(stat: &AppState) -> Option