AWS S3 File Storage
Store and serve files with AWS S3 using presigned URLs, multipart uploads, and lifecycle policies.
Overview
For web applications, presigned URLs are essential. They allow clients to upload files directly to S3 from the browser without exposing AWS credentials, and enable time-limited access to private objects. The @aws-sdk/s3-request-presigner package generates these URLs. Multipart uploads handle large files by splitting them into parts that are uploaded in parallel and assembled server-side.
S3 provides storage classes for cost optimization (Standard, Infrequent Access, Glacier, Intelligent-Tiering), lifecycle policies for automatic transitions and expirations, event notifications for triggering Lambda functions on upload, and S3 Select for running SQL queries directly on stored CSV/JSON/Parquet files. The S3-compatible API is also implemented by services like Cloudflare R2, MinIO, and DigitalOcean Spaces.
Who Is This For?
- Upload user files with presigned URLs from the browser
- Serve static assets and media through S3 with CloudFront CDN
- Implement multipart uploads for large file handling
- Set up lifecycle policies for log archival to Glacier
Installation
npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner Configuration
import { S3Client, PutObjectCommand, GetObjectCommand } from "@aws-sdk/client-s3"
import { getSignedUrl } from "@aws-sdk/s3-request-presigner"
const s3 = new S3Client({ region: "us-east-1" })
// Generate upload presigned URL
const uploadUrl = await getSignedUrl(s3,
new PutObjectCommand({ Bucket: "my-bucket", Key: "uploads/photo.jpg" }),
{ expiresIn: 3600 }
)
// Upload from server
await s3.send(new PutObjectCommand({
Bucket: "my-bucket",
Key: "uploads/file.pdf",
Body: fileBuffer,
ContentType: "application/pdf",
})) Explore AI Tools
Discover the best AI tools that complement your skills
Read AI & Design Articles
Tips and trends in the world of design and AI
Related Servers
Sentry Error Tracking
Monitor errors and performance issues in production with Sentry. AI agents can triage alerts and suggest fixes based on stack traces.
PostHog Product Analytics
Track product usage, manage feature flags, and analyze user behavior with PostHog, an open-source product analytics platform.
Database Query Builder
Generate and optimize SQL queries with AI assistance. Build complex queries, analyze execution plans, and improve database performance.