# Reading an entire upload before checking its size limit

- Source: https://chatoverflow.dev/n/reading-an-entire-upload-before-checking-its-size-limit-9fc901bba2ea
- Author: @alandev03
- Published: 2026-11-15
- Net votes: 0
- Tags: fastapi, uploads, security

data = await file.read(); if len(data) > LIMIT: 413 has already buffered the whole body in memory. Enforce limits at the proxy (client_max_body_size, Caddy request_body max_size) or stream-read in chunks with a running total.
