Fixed mime types of photo/video get

This commit is contained in:
Profitroll 2023-06-22 13:51:04 +02:00
parent b46f3fb0fd
commit 19e0531a24
Signed by: profitroll
GPG Key ID: FA35CAB49DACD3B2
2 changed files with 22 additions and 6 deletions

View File

@ -266,10 +266,18 @@ if configGet("media_token_access") is True:
return Response(image_file, media_type=mime) return Response(image_file, media_type=mime)
photo_get_responses = {404: PhotoNotFoundError("id").openapi} photo_get_responses = {
200: {"content": {"image/*": {}}},
404: PhotoNotFoundError("id").openapi,
}
@app.get("/photos/{id}", description="Get a photo by id", responses=photo_get_responses) @app.get(
"/photos/{id}",
description="Get a photo by id",
responses=photo_get_responses,
response_class=Response,
)
async def photo_get( async def photo_get(
id: str, id: str,
current_user: User = Security(get_current_active_user, scopes=["photos.read"]), current_user: User = Security(get_current_active_user, scopes=["photos.read"]),

View File

@ -92,10 +92,18 @@ async def video_upload(
) )
video_get_responses = {404: VideoNotFoundError("id").openapi} video_get_responses = {
200: {"content": {"video/*": {}}},
404: VideoNotFoundError("id").openapi,
}
@app.get("/videos/{id}", description="Get a video by id", responses=video_get_responses) @app.get(
"/videos/{id}",
description="Get a video by id",
responses=video_get_responses,
response_class=Response,
)
async def video_get( async def video_get(
id: str, id: str,
current_user: User = Security(get_current_active_user, scopes=["videos.read"]), current_user: User = Security(get_current_active_user, scopes=["videos.read"]),
@ -113,10 +121,10 @@ async def video_get(
mime = Magic(mime=True).from_file(video_path) mime = Magic(mime=True).from_file(video_path)
with aiofiles.open(video_path, "rb") as f: async with aiofiles.open(video_path, "rb") as f:
video_file = await f.read() video_file = await f.read()
return Response(video_file, media_type=mime) return Response(content=video_file, media_type=mime)
video_move_responses = {404: VideoNotFoundError("id").openapi} video_move_responses = {404: VideoNotFoundError("id").openapi}