upload
Technical notes on web development, DevOps, and AI integration.
3 articles
- 20:49backend
One Upload Limit, Four Layers
An 8 MiB upload cap is not one setting. FastAPI never rejects big files; the real gates are the browser, nginx, and Next.js.
TL;DR: An 8.5 MiB upload stalled silently, and debugging showed the FastAPI backend wasn't the culprit. Instead, size limits hide across the whole stack: browser Blob.size, nginx's client_max_body_size, and Next.js's bodySizeLimit, which counts multipart overhead rather than just the file. Consistent enforcement means aligning one limit constant across all four layers.
#file-upload#nginx#fastapi - 04:42backend
Four Contracts Behind a Public Upload Form
One multipart endpoint enforces four contracts: closed enums, conditional file slots, bounded streaming, and safe schema migration.
TL;DR: The upload form enforces four contracts: hand-maintained Go enums for validation, files that become required only when a flag says so, streaming writes capped at 10 MiB with magic-byte checks into private storage, and schema migrations that clean up enum values before narrowing on rollback. All four must stay synchronized server-side. Any drift breaks the endpoint predictably.
#go#multipart#file-upload - 13:50backend
From Full Buffering to Streaming Uploads in Go
Five slots times 10 MiB per request is a DoS invitation. A per-user rate limit plus multipart streaming cuts memory to roughly 1 MiB per request.
TL;DR: Buffering five 10 MiB uploads per request risked gigabytes under concurrent load, since a per-request cap doesn't limit request frequency. A per-user rate limiter of 30 requests per minute returns 429 with Retry-After to cap waves. Streaming with a 1 MiB memory window keeps each request near 1 MiB regardless of file size.
#go#security#upload