feat: Improve recipe assets preview (#6602)

Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com>
This commit is contained in:
Arsène Reymond
2026-01-31 15:48:42 +01:00
committed by GitHub
parent 9030c7e6b9
commit 719bd89eb1
2 changed files with 97 additions and 52 deletions

View File

@@ -53,7 +53,7 @@ async def get_recipe_asset(recipe_id: UUID4, file_name: str):
"""Returns a recipe asset"""
file = Recipe.directory_from_id(recipe_id).joinpath("assets", file_name)
try:
return FileResponse(file, content_disposition_type="attachment", filename=file_name)
except Exception as e:
raise HTTPException(status.HTTP_404_NOT_FOUND) from e
if file.exists():
return FileResponse(file)
else:
raise HTTPException(status.HTTP_404_NOT_FOUND)