Start here. This is the direct spoken answer to practice first.
Overview
An uploaded file is untrusted content and metadata, not just a convenient Python file object.
For nontrivial uploads I use FastAPI's UploadFile, which exposes a file-like interface and can spool data instead of requiring the entire upload as bytes in memory. I enforce request and file-size limits at the proxy or server and again while consuming the upload. I do not trust the submitted filename or content type; I generate my own storage name and inspect the file signature and allowed format. Temporary files and partial storage are cleaned up on validation failure or cancellation.