diff options
author | metamuffin <metamuffin@disroot.org> | 2023-06-16 19:23:00 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-06-16 19:23:00 +0200 |
commit | 1e66a718f9921c6d2bd0d54fb8eee26c7c7cc0af (patch) | |
tree | f69db4011d500e91c4eb69e0d33949fd92c22cb0 | |
parent | 7c82c24297a9da9a80bcac697e38d87206b3e440 (diff) | |
download | jellything-1e66a718f9921c6d2bd0d54fb8eee26c7c7cc0af.tar jellything-1e66a718f9921c6d2bd0d54fb8eee26c7c7cc0af.tar.bz2 jellything-1e66a718f9921c6d2bd0d54fb8eee26c7c7cc0af.tar.zst |
set asset content type
-rw-r--r-- | server/src/routes/api/mod.rs | 6 | ||||
-rw-r--r-- | server/src/routes/ui/node.rs | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/server/src/routes/api/mod.rs b/server/src/routes/api/mod.rs index f73ad05..fab60c6 100644 --- a/server/src/routes/api/mod.rs +++ b/server/src/routes/api/mod.rs @@ -62,7 +62,11 @@ pub async fn r_api_assets_node( .context("retrieving library node")?; let path = node.get_asset(library, role); info!("loading asset from {path:?}"); - Ok((ContentType::WEBP, File::open(path).await?)) + let ext = path.extension().unwrap().to_str().unwrap(); + Ok(( + ContentType::from_extension(ext).unwrap(), + File::open(path).await?, + )) } #[get("/api/node/<path..>")] diff --git a/server/src/routes/ui/node.rs b/server/src/routes/ui/node.rs index 46ab682..989f655 100644 --- a/server/src/routes/ui/node.rs +++ b/server/src/routes/ui/node.rs @@ -154,5 +154,9 @@ pub async fn r_item_assets( .context("retrieving library node")?; let path = node.get_asset(library, role); info!("loading asset from {path:?}"); - Ok((ContentType::WEBP, File::open(path).await?)) + let ext = path.extension().unwrap().to_str().unwrap(); + Ok(( + ContentType::from_extension(ext).unwrap(), + File::open(path).await?, + )) } |