✨ Added s3 storage
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
import re
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from fastapi.responses import StreamingResponse
|
||||
from fastapi.responses import StreamingResponse, RedirectResponse
|
||||
|
||||
from classquiz.config import settings, storage
|
||||
from classquiz.storage.errors import DownloadingFailedError
|
||||
@@ -21,6 +21,9 @@ file_regex = r"^[a-z0-9]{8}-[a-z0-9-]{27}--[a-z0-9-]{36}$"
|
||||
async def download_file(file_name: str):
|
||||
if not re.match(file_regex, file_name):
|
||||
raise HTTPException(status_code=400, detail="Invalid file name")
|
||||
if storage.backend == "s3":
|
||||
print("redir")
|
||||
return RedirectResponse(url=await storage.get_url(file_name, 300))
|
||||
try:
|
||||
download = await storage.download(file_name)
|
||||
except DownloadingFailedError:
|
||||
|
||||
Reference in New Issue
Block a user