improve formatting
This commit is contained in:
parent
3f93212424
commit
61e65a55ad
@ -369,6 +369,7 @@ pub struct S3Config {
|
|||||||
pub hostname: String,
|
pub hostname: String,
|
||||||
// may be useful when using self hosted s3. Won't work with recent AWS buckets
|
// may be useful when using self hosted s3. Won't work with recent AWS buckets
|
||||||
pub path_style: bool,
|
pub path_style: bool,
|
||||||
|
// http or https
|
||||||
pub protocol: String,
|
pub protocol: String,
|
||||||
|
|
||||||
// download directly from s3 to user, wihout going through Plume. Require public read on bucket
|
// download directly from s3 to user, wihout going through Plume. Require public read on bucket
|
||||||
|
@ -108,7 +108,6 @@ fn save_uploaded_file(file: &SavedField) -> Result<Option<String>, plume_models:
|
|||||||
Some(ext.to_lowercase())
|
Some(ext.to_lowercase())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(|ext| format!(".{}", ext))
|
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
@ -120,7 +119,7 @@ fn save_uploaded_file(file: &SavedField) -> Result<Option<String>, plume_models:
|
|||||||
{
|
{
|
||||||
use std::borrow::Cow;
|
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 {
|
let bytes = match file.data {
|
||||||
SavedData::Bytes(ref bytes) => Cow::from(bytes),
|
SavedData::Bytes(ref bytes) => Cow::from(bytes),
|
||||||
@ -143,7 +142,7 @@ fn save_uploaded_file(file: &SavedField) -> Result<Option<String>, plume_models:
|
|||||||
Ok(Some(dest))
|
Ok(Some(dest))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let dest = format!("{}/{}{}", CONFIG.media_directory, GUID::rand(), ext);
|
let dest = format!("{}/{}.{}", CONFIG.media_directory, GUID::rand(), ext);
|
||||||
|
|
||||||
match file.data {
|
match file.data {
|
||||||
SavedData::Bytes(ref bytes) => {
|
SavedData::Bytes(ref bytes) => {
|
||||||
|
@ -279,7 +279,7 @@ pub fn plume_media_files(file: PathBuf) -> Option<CachedFile> {
|
|||||||
.unwrap_or(ContentType::Binary);
|
.unwrap_or(ContentType::Binary);
|
||||||
|
|
||||||
Some(CachedFile {
|
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)]),
|
cache_control: CacheControl(vec![CacheDirective::MaxAge(60 * 60 * 24 * 30)]),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user