feat(storage): save MIME type into storage service

This commit is contained in:
MingxuanGame
2025-08-30 12:36:43 +00:00
parent c167cbcea6
commit 7d79f3cee7
6 changed files with 16 additions and 21 deletions

View File

@@ -135,7 +135,7 @@ def truncate(text: str, limit: int = 100, ellipsis: str = "...") -> str:
return text
def check_image(content: bytes, size: int, width: int, height: int) -> None:
def check_image(content: bytes, size: int, width: int, height: int) -> str:
if len(content) > size: # 10MB limit
raise HTTPException(status_code=400, detail="File size exceeds 10MB limit")
elif len(content) == 0:
@@ -149,6 +149,7 @@ def check_image(content: bytes, size: int, width: int, height: int) -> None:
status_code=400,
detail=f"Image size exceeds {width}x{height} pixels",
)
return img.format.lower()
except Exception as e:
raise HTTPException(status_code=400, detail=f"Error processing image: {e}")