Skip to the page

Scaling and running in production · mid

File storage: S3 and presigned URLs

Store files in object storage like S3, not on the API server's disk, and let clients upload and download directly with short-lived presigned URLs, while your API only checks permissions, chooses keys and records metadata.

The notes

What you must know

  • Local disk does not work with several instances or containers (files vanish on redeploy); object storage is durable, cheap and scales.
  • Presigned URL: a URL signed with your credentials that allows one operation (PUT or GET) on one key until it expires. SigV4 allows up to 7 days with IAM user credentials, but a URL made with temporary credentials (an IAM role) dies when they expire.
  • Upload flow: the API authorises, picks a key (uuid, not the user's file name), returns a presigned PUT (or a presigned POST policy, which can limit size and type); the client uploads; S3 events or a 'complete' call trigger processing.
  • Keep buckets private (Block Public Access); serve public assets through a CDN (CloudFront with Origin Access Control) and private files through presigned GET URLs or CloudFront signed URLs.
  • Big files: multipart upload (parallel parts, resume failed parts); images: resize to several sizes in a background job.
  • Store metadata (owner, size, type, status) in your database; the object key is just a pointer.

The red pen

Common traps: mistake → fix

  • Mistake: Proxy uploads through the API so you can check them

    Fix: it doubles bandwidth and ties up servers; check permissions before and the file after.

  • Mistake: Make the bucket public for simplicity

    Fix: anyone can list or guess keys; keep it private and use a CDN or signed URLs.

Easy to hard

Questions interviewers ask, easy to hard

  1. Where do you store user uploads and why not on the server's disk?
  2. How does a presigned URL work? How long should it live?
  3. How do you serve private files (invoices, KYC documents) securely?
  4. How do you handle a 2 GB video upload on a flaky mobile network?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview