This small project demonstrates how to upload large video files from a browser into an S3 bucket using multipart uploads and presigned URLs.
Contents:
server/- Express server that creates multipart uploads and returns presigned URLs for parts.frontend/- Simple HTML + JS UI that chunks files and uploads parts in parallel.
Requirements
- Node 16+ (or a recent LTS)
- An existing S3 bucket you can write to
Environment
Create a .env file in the project root with these variables:
AWS_ACCESS_KEY_ID=YOUR_KEY
AWS_SECRET_ACCESS_KEY=YOUR_SECRET
AWS_REGION=us-east-1
BUCKET_NAME=your-target-bucket
PORT=3000
How it works
- Browser: splits each file into ~8 MiB parts, requests a presigned PUT URL per part from the server, uploads parts directly to S3, then calls server to complete the multipart upload.
- Server: uses AWS SDK v3 to create multipart uploads, generate presigned URLs for UploadPart, and complete multipart uploads.
Run locally
- Install deps
cd ~/Desktop/s3-multipart-upload
npm install- Start the server
npm start- Open
frontend/index.htmlin the browser (file://) or serve it with a static server. Set the backend URL tohttp://localhost:3000and pick files to upload.
Notes & next steps
- This example does not implement resume across page reloads or long-term tracking of incomplete uploads. For resumes you should persist uploadId and uploaded parts metadata.
- You may want to implement an abort endpoint to cleanup unfinished uploads.
- Adjust
PART_SIZEinfrontend/main.jsfor different chunk sizes (must be >= 5 MiB except last part).