@@ -178,14 +178,64 @@ pub mod endpoint {
|
||||
file_type
|
||||
);
|
||||
|
||||
match repo::coverart::insert(&pool, &raw_data, &file_type.file_type).await {
|
||||
Ok(id) => {
|
||||
response.message = String::from("Successful");
|
||||
response.data.push(id);
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
let data = labyrinth::Data {
|
||||
raw_data: raw_data,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let filename = simodels::coverart::generate_filename(
|
||||
simodels::types::CoverArtType::JpegExtension,
|
||||
true,
|
||||
)
|
||||
.unwrap();
|
||||
let file_path = format!("queued/coverart/{filename}");
|
||||
|
||||
println!("Key: {file_path:?}");
|
||||
|
||||
match lr.upload(&file_path, &data).await {
|
||||
Ok(_res) => {
|
||||
match repo::coverart::insert(
|
||||
&pool,
|
||||
&data.raw_data,
|
||||
&file_type.file_type,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(id) => {
|
||||
match repo::data::insert(
|
||||
&pool,
|
||||
&file_path,
|
||||
&lr.config.bucket,
|
||||
&lr.config.region,
|
||||
&id,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_id) => {
|
||||
response.message = String::from("Successful");
|
||||
response.data.push(id);
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(
|
||||
axum::http::StatusCode::BAD_REQUEST,
|
||||
axum::Json(response),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
eprintln!("Error: {err:?}");
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user