Fix Python libmagic syntax

See: #201
This commit is contained in:
Yannik Rödel 2025-10-29 04:22:30 +01:00
parent 3d850eb121
commit da40de2759

View file

@ -173,8 +173,7 @@ def get_form_value(
): ):
fail("400 Bad Request", f"Invalid value for field: {name}") fail("400 Bad Request", f"Invalid value for field: {name}")
data = value_object.file.read() data = value_object.file.read()
with magic.Magic() as magic_instance: mime_type = magic.from_buffer(data, mime=True)
mime_type = magic_instance.from_buffer(data)
if mime_type not in VALID_MIME_TYPES: if mime_type not in VALID_MIME_TYPES:
fail("400 Bad Request", f"Invalid MIME type {mime_type} for upload: {name}") fail("400 Bad Request", f"Invalid MIME type {mime_type} for upload: {name}")
return (value_object.filename or "upload"), data return (value_object.filename or "upload"), data