Pre-signed S3 upload from the browser

5422
0

Large file uploads don’t belong on app servers. My default is: the server issues a short-lived pre-signed URL, the browser uploads directly to S3, then the server stores the object key. That keeps latency low and costs predictable. Before signing, I validate content-type and max size because pre-signed URLs are effectively temporary credentials. I also include a random prefix and the user id in the key so listing and cleanup are easy later. Finally, I store only the key in the DB (not a full URL) so I can change bucket/CDN settings without rewriting records. This pattern scales cleanly and keeps your API instances focused on CPU-bound work.