AWS Builder Center

Why You Shouldn't Upload Files Through Your Backend (Use S3 Presigned URLs Instead)

A practical guide on eliminating server bottlenecks and high memory usage by allowing clients to upload directly to Amazon S3 using presigned URLs.

Electronic Engineering Student
When building applications that accept file uploads (profile pictures, PDFs, videos, or raw datasets), the traditional approach is to route the file through your backend server:
 Client Browser -> Backend API -> Amazon S3 
While this works for tiny payloads, it introduces severe bottlenecks as your application grows.



The Hidden Costs of Proxying Uploads

  1. Memory Bloat: Holding large multi-part file buffers in backend server memory consumes resources and limits concurrency.
  1. Double Bandwidth: You pay network transfer and CPU time to ingest the file, and then pay again to forward those exact bytes to S3.
  1. Serverless Timeouts: Routing large uploads through AWS Lambda can easily hit execution timeouts or API Gateway's 10 MB payload limit.



The Solution: Direct Uploads via S3 Presigned URLs

Instead of handling the raw file transfer, your backend simply acts as a gatekeeper:
  1. Client Request: The client asks the backend for permission to upload a specific file name.
  1. URL Generation: The backend uses the AWS SDK to generate a time-limited S3 Presigned URL (e.g., valid for 5 minutes) scoped strictly to  PutObject .
  1. Direct Upload: The backend returns the URL to the client, which uploads the file directly to Amazon S3 via a standard HTTP PUT request.



Key Architectural Benefits

  • Zero Backend Load: Your API Gateway or compute instances only handle a lightweight JSON request, leaving file streaming to AWS's global edge network.
  • Granular Security: You control exactly who can upload, where the file goes, and how long the upload window stays open.
  • Event-Driven Chaining: Once the file reaches S3, you can trigger downstream processing automatically using S3 Event Notifications to AWS Lambda.



Let's Discuss! 🛠️

Have you implemented direct-to-S3 uploads in your projects, or do you still process files through your backend servers? Share your architectural patterns in the comments below!
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article