From 9cbb502cf3e3bfc5b891f2ab318a7c79c17b49ba Mon Sep 17 00:00:00 2001 From: Mawoka Date: Mon, 12 Jun 2023 20:46:40 +0200 Subject: [PATCH] :ambulance: Fixed Storage download endpoint --- classquiz/routers/storage.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/classquiz/routers/storage.py b/classquiz/routers/storage.py index 17e4792..3bcf4a5 100644 --- a/classquiz/routers/storage.py +++ b/classquiz/routers/storage.py @@ -47,7 +47,10 @@ async def download_file(file_name: str): if file_name is None: file_name = item.id.hex if storage.backend == "s3": - return RedirectResponse(url=await storage.get_url(file_name, 300), headers=headers_from_storage_item(item)) + if item is None: + return RedirectResponse(url=await storage.get_url(file_name, 300)) + else: + return RedirectResponse(url=await storage.get_url(file_name, 300), headers=headers_from_storage_item(item)) try: download = await storage.download(file_name) except DownloadingFailedError: