Users upload files up to 5 GB that must be virus-scanned and processed. Design the upload flow.

Short answer

Let clients upload directly to object storage with pre-signed multipart upload URLs, keep files in a quarantine bucket, trigger asynchronous scanning and processing via storage events and queues, move clean files to the main bucket, update status for the client, and enforce size, type and authorization checks before issuing upload URLs.

Detailed answer

sequenceDiagram
  participant C as Client
  participant API as Upload API
  participant S3 as Object storage (quarantine)
  participant Q as Queue
  participant SCAN as Scanner workers
  C->>API: request upload (name, size, type)
  API-->>C: multipart pre-signed URLs + uploadId
  C->>S3: upload parts directly (resumable)
  C->>API: complete upload
  S3--)Q: object created event
  Q->>SCAN: scan + process
  SCAN->>S3: move clean file to main bucket / quarantine infected
  SCAN->>API: status update
  API-->>C: status via polling or push

What the interviewer expects

Direct-to-storage uploads, async processing, security controls.

Common mistakes to avoid

Streaming large files through application servers; processing before scanning.