Loading...
Loading...
Rechazo de payloads que excedan el tamaño máximo permitido para prevenir ataques DoS
npx skill4agent add davidcastagnetoa/skills input_size_validationclient_max_body_size 20M;UploadFileMAX_IMAGE_SIZE = 10 * 1024 * 1024 # 10 MB por imagen
async def validate_image(file: UploadFile):
content = await file.read(MAX_IMAGE_SIZE + 1)
if len(content) > MAX_IMAGE_SIZE:
raise HTTPException(413, "Imagen demasiado grande. Máximo 10MB.")
await file.seek(0)
return contentimage/jpegimage/pngcapture_agent