Scrivio Interview library
DesignIntermediate6 min read · updated 13 November 2026

A marketplace receives 2 million photo and video uploads a day from mobile apps, up to 2 GB each. Today uploads pass through Spring Boot pods, which run out of memory and disk at peak.

Design the upload and processing path so files go straight to object storage, are checked before anyone can see them, and are served efficiently.

The client asks the API for an upload, the service records a PENDING row and returns a presigned PUT, POST or multipart upload limited by size and type, and the file goes straight into a private quarantine bucket. A storage event triggers idempotent workers that scan, sniff the type and transcode; only files that pass are copied to the public-content bucket and marked READY, while rejected ones are deleted by a lifecycle rule. Content is served through a CDN with signed URLs and immutable keys, and incomplete multipart uploads are aborted automatically.

Why this question is asked

Uploads that pass through application servers are a classic scaling trap. A Spring Boot pod that buffers a 2 GB video holds memory or disk for minutes, and at peak the pods run out of both, which is exactly what the overview describes. Interviewers ask this design because it touches many parts at once: presigned URLs, multipart upload, event-driven processing, safety checks before anyone can see a file, CDN delivery and idempotency. In this answer, we will size the problem, design the upload request and the direct upload, build the quarantine and processing pipeline, publish and serve the files, and cover clean-up and repeated events, including the follow-up about stopping oversized uploads.

1Rough Numbers First

Two million uploads a day is about 23 per second on average, perhaps 100 per second at peak. If most are photos of 3 MB and a tenth are videos averaging 200 MB, daily ingest is about 5 TB of photos and about 40 TB of video, so around 45 TB a day before processing. Pushing that through application pods means sustained tens of gigabits per second and huge buffers. Object storage handles this volume easily, because it was built to accept parallel uploads from millions of clients. So the design goal is simple: our services handle small JSON requests, and the bytes never touch them.

2Requesting an Upload and Uploading Directly

The mobile app first calls the API with the file's size, content type and checksum. The service checks the user's rights and quotas, creates a metadata row with status PENDING, chooses a random key, and returns a way to upload. For photos, that is a presigned POST, whose signed policy can include conditions such as a content-length-range of 1 byte to 20 MB and an exact Content-Type. For videos above a threshold, say 100 MB, the service starts a multipart upload and returns presigned URLs for each part, for example 64 MB parts, so the app can upload parts in parallel and resume after a network drop.

The files land in a private quarantine bucket, or a quarantine prefix, that no user can read. Nothing in it is ever linked from the product.

Step throughUpload and processing
AppUpload APIQuarantine bucketWorkerContent bucket
request upload: size, type, checksum
row status PENDING, random key
presigned POST or multipart part URLs
upload bytes directly
object created event (via queue)
scan, sniff type, transcode, thumbnails
copy approved renditions
status READY or REJECTED

8 messages in order. Play them, or step through them one at a time.

3Checking Files Before Anyone Can See Them

When an object lands, the storage event notification, for example an S3 event delivered to an SQS queue, triggers processing. Putting a queue between the event and the workers lets us absorb bursts, retry failures, and send repeated failures to a dead-letter queue. Workers then check the file properly. They sniff the real type from the file's first bytes, because the Content-Type the client claims proves nothing; a photo upload that is actually an executable is rejected. They run a malware scan, such as ClamAV in our own workers or a managed scanning service. They check dimensions, duration and any content policy. Then they produce derived files: resized images and thumbnails for photos, and transcoded renditions, such as HLS segments at several bitrates, for videos, often through a managed transcoding service for video.

Only when all checks pass does the worker copy the approved files to the public-content bucket under new immutable keys and mark the row READY. If a check fails, it marks the row REJECTED with a reason. The quarantine bucket has a lifecycle rule that deletes objects after a few days, so rejected and processed originals clean themselves up unless we choose to keep originals elsewhere.

4Serving Through a CDN

The public-content bucket is still private to the internet; only the CDN can read it, for example CloudFront with origin access control. Public listing photos are served with long cache lifetimes. Private content, such as documents shared only with a buyer, uses CDN signed URLs or signed cookies, generated by the API after a permission check and valid for minutes.

Keys are immutable: if a seller replaces a photo, the new version gets a new key, and the row points to it. So we can cache every object for a year with Cache-Control immutable, never need to purge the CDN for an update, and avoid users seeing a mix of old and new versions.

Java
// The product page links to CDN URLs built from the row, never to the bucket
String url = "https://media.example.com/" + row.renditionKey("w800");
// response header on every rendition
// Cache-Control: public, max-age=31536000, immutable

5Clean-Up and Idempotency

Two failure modes need explicit handling. First, abandoned multipart uploads: parts that were uploaded but never completed are stored and billed, yet invisible in normal listings. A lifecycle rule that aborts incomplete multipart uploads after, say, 3 days removes them. A periodic job also expires PENDING rows that never received a file.

Second, storage events are delivered at least once, so the same object-created event can arrive twice, and a worker can crash halfway. Every step must be idempotent: the worker uses the object key as the job identity, transitions the row only from PENDING to PROCESSING to READY with a conditional update, and writes renditions to deterministic keys, so a repeated job overwrites the same files rather than creating new ones.

Step throughLifecycle of one upload
  1. PENDINGrow created, presigned URL issued
  2. Object arrives in quarantine?
    YesPROCESSINGNoExpire row after a timeout
  3. Checks pass?
    YesCopy to content bucket, READYNoREJECTED, lifecycle deletes the object
  4. Served by CDNsigned URL for private content

4 steps in order. Play them, or step through them one at a time.

6Follow-up questions

How do you stop a client from uploading a 50 GB file with a presigned URL meant for a photo?

We put the limit into the signature. A presigned POST policy carries a content-length-range condition, so S3 rejects anything larger than, say, 20 MB. For a presigned PUT, we sign the Content-Length header so the client must send exactly the declared size, and the API refuses declared sizes over the limit. For multipart, the service decides how many part URLs to issue and checks the total size before calling CompleteMultipartUpload. As a final guard, the worker checks the real object size and rejects anything over the limit.

Why not let clients upload directly to the content bucket and scan afterwards?

Because there would be a window, possibly minutes, when unscanned content is publicly reachable, and some bad files would be cached by the CDN. Quarantine first makes it impossible to serve a file before it passed the checks.

How long should a presigned URL be valid?

Long enough for the upload to start, typically 5 to 15 minutes for photos. For multipart uploads, each part URL can be requested when needed, so long uploads do not need long-lived URLs.

7Conclusion

In this answer, we designed an upload path where the bytes never touch our pods. The API creates a PENDING row and returns a presigned POST or multipart upload with size and type conditions, the file lands in a private quarantine bucket, and an event through a queue drives idempotent workers that sniff the type, scan, and transcode. Only approved files are copied to the content bucket and marked READY, served through a CDN with immutable keys and signed URLs for private content, and lifecycle rules remove rejected files and abandoned multipart uploads.

What to say in the interviewAbout 80 seconds aloud

Open with

The key idea is that our Spring Boot pods only handle small requests and the bytes go straight to object storage. The app asks the API for an upload with the size, type and checksum.

Then, if they want more

The service creates a metadata row with status PENDING and a random key, and returns a presigned POST with a content-length-range and content type condition, or for large videos a multipart upload with presigned part URLs, so uploads are parallel and resumable. Files land in a private quarantine bucket.

The object-created event goes through a queue to workers that sniff the real file type, run a malware scan, and transcode or make thumbnails. Only if everything passes does the worker copy the renditions to the content bucket under immutable keys and mark the row READY; failures are REJECTED and a lifecycle rule deletes the quarantined object.

Everything is served through a CDN with long cache lifetimes, and private content gets signed URLs or cookies. Because events are at least once, every step is idempotent, keyed by the object key with conditional status updates. And a lifecycle rule aborts incomplete multipart uploads after a few days, since those parts are billed but invisible.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Design the upload and processing path so files go straight to object storage, are...": https://scrivio-interview-library.netlify.app/architecture/storage-and-pipelines/90ad52497c/