feat: complete multimodal ticket intake
This commit is contained in:
@@ -30,8 +30,9 @@ FORMATS = {
|
||||
|
||||
|
||||
def prepare_image(raw: bytes, original_name: str) -> PreparedImage:
|
||||
if len(raw) > 10 * 1024 * 1024:
|
||||
raise DraftImageError(413, "单张图片不能超过 10 MB")
|
||||
max_bytes = settings.TICKET_MATERIAL_MAX_FILE_BYTES
|
||||
if len(raw) > max_bytes:
|
||||
raise DraftImageError(413, f"单个材料不能超过 {max_bytes // 1024 // 1024} MB")
|
||||
try:
|
||||
with Image.open(io.BytesIO(raw)) as image:
|
||||
image.verify()
|
||||
|
||||
Reference in New Issue
Block a user