Save medias in static/media

Fixes #272
pull/279/head
Bat 6 years ago
parent f7c37ca6ca
commit 14969d489c

3
.gitignore vendored

@ -7,7 +7,8 @@ translations
po/*.po~
.env
Rocket.toml
media
!.gitkeep
static/media
docker-compose.yml
*.db
*.sqlite

@ -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

@ -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/<file..>", rank = 1)]
fn static_files(file: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new("media/").join(file)).ok()
}

Loading…
Cancel
Save