tsk-203: Addressing hard coding when downloading coverart
This commit is contained in:
+11
-3
@@ -179,17 +179,25 @@ pub mod endpoint {
|
||||
match repo::coverart::get_coverart(&pool, &id).await {
|
||||
Ok(coverart) => match icarus_models::coverart::io::to_data(&coverart) {
|
||||
Ok(data) => {
|
||||
let file_type = match icarus_meta::detection::coverart::file_type_from_data(&data) {
|
||||
Ok(file_type) => {
|
||||
file_type
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
return (axum::http::StatusCode::INTERNAL_SERVER_ERROR, axum::response::Response::default());
|
||||
}
|
||||
};
|
||||
let bytes = axum::body::Bytes::from(data);
|
||||
let mut response = bytes.into_response();
|
||||
let headers = response.headers_mut();
|
||||
// TODO: Address hard coding
|
||||
headers.insert(
|
||||
axum::http::header::CONTENT_TYPE,
|
||||
"audio/jpg".parse().unwrap(),
|
||||
file_type.mime.parse().unwrap()
|
||||
);
|
||||
headers.insert(
|
||||
axum::http::header::CONTENT_DISPOSITION,
|
||||
format!("attachment; filename=\"{id}.jpg\"")
|
||||
format!("attachment; filename=\"{}\"", coverart.filename)
|
||||
.parse()
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user