# fastapi.exceptions.RequestValidationError: 1 validation error for Request\nbody -> file\n  file size exceeds limit (max: 1048576 bytes)

- **ID:** `python/fastapi-upload-file-size-exceeded`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

上传的文件超过 FastAPI 或服务器设置的限制。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   from fastapi import UploadFile\n@app.post('/upload')\nasync def upload(file: UploadFile):\n    content = await file.read()\n    if len(content) > 1048576:\n        raise HTTPException(413, 'File too large')\n    return {'size': len(content)}
   ```
2. **** (70% success)
   ```
   uvicorn --limit-max-requests 100 --limit-concurrency 10
   ```

## Dead Ends

- **** — 可能导致服务器内存耗尽。 (90% fail)
- **** — 无法控制所有客户端。 (40% fail)
