From 14969d489c61b92b928cdd72c30571da3c4b3939 Mon Sep 17 00:00:00 2001 From: Bat Date: Fri, 12 Oct 2018 20:22:57 +0100 Subject: [PATCH] Save medias in static/media Fixes #272 --- .gitignore | 3 ++- docs/INSTALL.md | 6 ------ src/routes/medias.rs | 7 +------ static/media/.gitkeep | 0 4 files changed, 3 insertions(+), 13 deletions(-) create mode 100644 static/media/.gitkeep diff --git a/.gitignore b/.gitignore index cc7661dc..f84fea6b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,8 @@ translations po/*.po~ .env Rocket.toml -media +!.gitkeep +static/media docker-compose.yml *.db *.sqlite diff --git a/docs/INSTALL.md b/docs/INSTALL.md index c55305a2..42dbdb73 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -193,12 +193,6 @@ plm users new --admin For more information about these commands, and the arguments you can give them, check out [their documentaion](CLI.md). -After that, you are almost done, the last thing to do is to create the media directory, where uploads will be stored: - -```bash -mkdir media -``` - Finally, you can start Plume with: ```bash diff --git a/src/routes/medias.rs b/src/routes/medias.rs index 011567e0..ce40c42b 100644 --- a/src/routes/medias.rs +++ b/src/routes/medias.rs @@ -39,7 +39,7 @@ fn upload(user: User, data: Data, ct: &ContentType, conn: DbConn) -> Redirect { let ext = filename.rsplitn(2, ".") .next() .unwrap(); - let dest = format!("media/{}.{}", GUID::rand().to_string(), ext); + let dest = format!("static/media/{}.{}", GUID::rand().to_string(), ext); if let SavedData::Bytes(ref bytes) = fields[&"file".to_string()][0].data { fs::write(&dest, bytes).expect("Couldn't save upload"); @@ -110,8 +110,3 @@ fn set_avatar(id: i32, user: User, conn: DbConn) -> Redirect { user.set_avatar(&*conn, media.id); Redirect::to(uri!(details: id = id)) } - -#[get("/static/media/", rank = 1)] -fn static_files(file: PathBuf) -> Option { - NamedFile::open(Path::new("media/").join(file)).ok() -} diff --git a/static/media/.gitkeep b/static/media/.gitkeep new file mode 100644 index 00000000..e69de29b