mirror of
https://github.com/azaion/detections.git
synced 2026-04-23 04:26:31 +00:00
[AZ-175] Restore image validation for corrupt/oversized uploads in /detect endpoint
Made-with: Cursor
This commit is contained in:
@@ -361,6 +361,11 @@ async def detect_image(
|
||||
orig_name = file.filename or "upload"
|
||||
kind, ext = _detect_upload_kind(orig_name, image_bytes)
|
||||
|
||||
if kind == "image":
|
||||
arr = np.frombuffer(image_bytes, dtype=np.uint8)
|
||||
if cv2.imdecode(arr, cv2.IMREAD_COLOR) is None:
|
||||
raise HTTPException(status_code=400, detail="Invalid image data")
|
||||
|
||||
config_dict = {}
|
||||
if config:
|
||||
config_dict = json.loads(config)
|
||||
|
||||
Reference in New Issue
Block a user