feat: enhance media management with EXIF data extraction, metadata filtering, and storage path generation

refactor: update configuration handling to use environment variables and improve code organization
This commit is contained in:
2025-11-14 11:22:51 +01:00
parent 70dc0a7131
commit 3c3b51a2a7
24 changed files with 393 additions and 181 deletions

View File

@@ -13,7 +13,7 @@ use tower::ServiceExt;
use tower_http::services::ServeFile;
use uuid::Uuid;
use crate::{error::ApiError, extractors::query_options::ApiListMediaOptions, middleware::auth::UserId, schema::MediaResponse, state::AppState};
use crate::{error::ApiError, extractors::query_options::ApiListMediaOptions, middleware::auth::UserId, schema::{MediaDetailsResponse, MediaMetadataResponse, MediaResponse}, state::AppState};
impl From<Media> for MediaResponse {
@@ -101,9 +101,22 @@ async fn get_media_details(
State(state): State<AppState>,
UserId(user_id): UserId,
Path(id): Path<Uuid>,
) -> Result<Json<MediaResponse>, ApiError> {
let media = state.media_service.get_media_details(id, user_id).await?;
Ok(Json(media.into()))
) -> Result<Json<MediaDetailsResponse>, ApiError> {
let bundle = state.media_service.get_media_details(id, user_id).await?;
let response = MediaDetailsResponse {
id: bundle.media.id,
storage_path: bundle.media.storage_path,
original_filename: bundle.media.original_filename,
mime_type: bundle.media.mime_type,
hash: bundle.media.hash,
metadata: bundle.metadata
.into_iter()
.map(MediaMetadataResponse::from)
.collect(),
};
Ok(Json(response))
}
async fn delete_media(