Skip to content

Commit

Permalink
🐛 Fix S3 upload not working
Browse files Browse the repository at this point in the history
  • Loading branch information
mawoka-myblock committed Jun 15, 2024
1 parent dcf3a1c commit 0e29a22
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions classquiz/routers/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ async def download_file_head(file_name: str) -> Response:


@router.post("/")
async def upload_file(
request: Request, file: UploadFile = File(), user: User = Depends(get_current_user)
) -> PublicStorageItem:
async def upload_file(file: UploadFile = File(), user: User = Depends(get_current_user)) -> PublicStorageItem:
if file.content_type not in ALLOWED_MIME_TYPES:
raise HTTPException(status_code=422, detail="Unsupported")
if user.storage_used > settings.free_storage_limit:
Expand All @@ -137,12 +135,11 @@ async def upload_file(
deleted_at=None,
alt_text=None,
)
print("File Size:", request.headers.get("Content-Length"))
await storage.upload(
file_name=file_id.hex,
file_data=file.file,
mime_type=file.content_type,
size=request.headers.get("Content-Length"),
size=size,
)
await file_obj.save()
await arq.enqueue_job("calculate_hash", file_id.hex)
Expand Down

0 comments on commit 0e29a22

Please sign in to comment.