feat: Add thumbnail path to MediaResponse and update related implementations
This commit is contained in:
@@ -6,7 +6,7 @@ use axum::{
|
||||
routing::{get, post},
|
||||
};
|
||||
use futures::TryStreamExt;
|
||||
use libertas_core::{error::CoreError, models::Media, schema::UploadMediaData};
|
||||
use libertas_core::{error::CoreError, schema::UploadMediaData};
|
||||
use std::{io, path::PathBuf};
|
||||
|
||||
use tower::ServiceExt;
|
||||
@@ -15,19 +15,6 @@ use uuid::Uuid;
|
||||
|
||||
use crate::{error::ApiError, extractors::query_options::ApiListMediaOptions, middleware::auth::UserId, schema::{MediaDetailsResponse, MediaMetadataResponse, MediaResponse}, state::AppState};
|
||||
|
||||
|
||||
impl From<Media> for MediaResponse {
|
||||
fn from(media: Media) -> Self {
|
||||
Self {
|
||||
id: media.id,
|
||||
storage_path: media.storage_path,
|
||||
original_filename: media.original_filename,
|
||||
mime_type: media.mime_type,
|
||||
hash: media.hash,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn media_routes(max_upload_size: usize) -> Router<AppState> {
|
||||
Router::new()
|
||||
.route("/", post(upload_media).get(list_user_media))
|
||||
@@ -109,6 +96,7 @@ async fn get_media_details(
|
||||
original_filename: bundle.media.original_filename,
|
||||
mime_type: bundle.media.mime_type,
|
||||
hash: bundle.media.hash,
|
||||
thumbnail_path: bundle.media.thumbnail_path,
|
||||
metadata: bundle.metadata
|
||||
.into_iter()
|
||||
.map(MediaMetadataResponse::from)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use libertas_core::models::{Album, AlbumPermission, FaceRegion, MediaMetadata, Person, PersonPermission, Tag};
|
||||
use libertas_core::models::{Album, AlbumPermission, FaceRegion, Media, MediaMetadata, Person, PersonPermission, Tag};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -9,6 +9,20 @@ pub struct MediaResponse {
|
||||
pub original_filename: String,
|
||||
pub mime_type: String,
|
||||
pub hash: String,
|
||||
pub thumbnail_path: Option<String>,
|
||||
}
|
||||
|
||||
impl From<Media> for MediaResponse {
|
||||
fn from(media: Media) -> Self {
|
||||
Self {
|
||||
id: media.id,
|
||||
storage_path: media.storage_path,
|
||||
original_filename: media.original_filename,
|
||||
mime_type: media.mime_type,
|
||||
hash: media.hash,
|
||||
thumbnail_path: media.thumbnail_path,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -118,6 +132,7 @@ pub struct MediaDetailsResponse {
|
||||
pub original_filename: String,
|
||||
pub mime_type: String,
|
||||
pub hash: String,
|
||||
pub thumbnail_path: Option<String>,
|
||||
pub metadata: Vec<MediaMetadataResponse>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user