file-upload
Technical notes on web development, DevOps, and AI integration.
2 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