Fixes and cleanups #11

Merged
profitroll merged 7 commits from dev into master 2023-06-22 14:52:23 +03:00
2 changed files with 22 additions and 6 deletions
Showing only changes of commit 19e0531a24 - Show all commits

View File

@ -266,10 +266,18 @@ if configGet("media_token_access") is True:
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(
id: str,
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(
id: str,
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)
with aiofiles.open(video_path, "rb") as f:
async with aiofiles.open(video_path, "rb") as f:
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}