From 61e65a55ad1f5094321c111e395d00dddcb05e96 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 15 May 2023 12:35:39 +0200 Subject: [PATCH] improve formatting --- plume-models/src/config.rs | 1 + src/routes/medias.rs | 5 ++--- src/routes/mod.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plume-models/src/config.rs b/plume-models/src/config.rs index dc27497b..12441a75 100644 --- a/plume-models/src/config.rs +++ b/plume-models/src/config.rs @@ -369,6 +369,7 @@ pub struct S3Config { pub hostname: String, // may be useful when using self hosted s3. Won't work with recent AWS buckets pub path_style: bool, + // http or https pub protocol: String, // download directly from s3 to user, wihout going through Plume. Require public read on bucket diff --git a/src/routes/medias.rs b/src/routes/medias.rs index 05119d23..5f4b966d 100644 --- a/src/routes/medias.rs +++ b/src/routes/medias.rs @@ -108,7 +108,6 @@ fn save_uploaded_file(file: &SavedField) -> Result, plume_models: Some(ext.to_lowercase()) } }) - .map(|ext| format!(".{}", ext)) }) .unwrap_or_default(); @@ -120,7 +119,7 @@ fn save_uploaded_file(file: &SavedField) -> Result, plume_models: { use std::borrow::Cow; - let dest = format!("static/media/{}{}", GUID::rand(), ext); + let dest = format!("static/media/{}.{}", GUID::rand(), ext); let bytes = match file.data { SavedData::Bytes(ref bytes) => Cow::from(bytes), @@ -143,7 +142,7 @@ fn save_uploaded_file(file: &SavedField) -> Result, plume_models: Ok(Some(dest)) } } else { - let dest = format!("{}/{}{}", CONFIG.media_directory, GUID::rand(), ext); + let dest = format!("{}/{}.{}", CONFIG.media_directory, GUID::rand(), ext); match file.data { SavedData::Bytes(ref bytes) => { diff --git a/src/routes/mod.rs b/src/routes/mod.rs index 5b4adb6f..11c22825 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -279,7 +279,7 @@ pub fn plume_media_files(file: PathBuf) -> Option { .unwrap_or(ContentType::Binary); Some(CachedFile { - inner: FileKind::S3 ( data.to_vec(), ct), + inner: FileKind::S3(data.to_vec(), ct), cache_control: CacheControl(vec![CacheDirective::MaxAge(60 * 60 * 24 * 30)]), }) }