How would you build a feature that lets users upload profile photos and PDF documents up to 100 MB?
What the interviewer wants to hear
- Upload directly to object storage with presigned URLs
- Validate file type and size on the server
- Store only metadata and object key in the database
- Process files asynchronously, such as resizing or virus scanning
- Serve through a CDN with access control for private files
Model answer
I would not send large files through my API server, because it ties up memory and hits serverless body limits. Instead the client asks my API for an upload URL. The server checks the user is logged in, checks the declared file type and size, and returns a short-lived presigned URL for object storage like S3 or R2. The browser uploads directly to storage, using multipart upload for big files so it can resume. When the upload finishes, the client tells my API, or a storage event triggers it, and I save metadata like the object key, size, type and owner in the database. A background job then checks the real file type, scans for viruses and creates resized images. Public images are served through a CDN, while private PDFs are served with short-lived signed URLs after an authorization check.
Can you answer it under time pressure?
Take a timed medium round and get scored on every answer.
More medium Full Stack Developer questions
- How would you implement login for a web app? Compare server sessions with JWT access tokens and explain what you would choose.
- Users say the orders page is slow. How do you find and fix the problem across frontend, API and database?
- Your API is used by a web app and an older mobile app that users do not update quickly. How do you make a breaking change safely?
- Describe a good CI/CD pipeline for a full stack app. What runs on each pull request and how do you deploy safely?
- You need to build a product search page with text search, filters and sorting. Walk through the design from the UI to the database.
- How would you add role-based access control (admin, editor, viewer) to an existing full-stack app?
- What is your testing strategy for a full-stack feature such as "invite a teammate by email"?
- Describe the different layers where you can cache in a typical full-stack web app, and how you keep cached data correct.
- You need to show in-app notifications in real time. How do you choose between polling, server-sent events and WebSockets, and how would you build it?