Overview
EaseLMS uses AWS S3 for object storage with optional CDN integration (CloudFront or Azure Front Door) for global content delivery. The system supports videos, images, documents, and certificates with intelligent path management and deduplication.Storage Architecture
S3 Client Configuration
The S3 client is configured with AWS SDK v3:lib/aws/s3.ts
Environment Variables
.env.local
File Organization Structure
EaseLMS uses a hierarchical S3 key structure for organization:Path Generation
ThegetS3StoragePath function generates standardized paths:
lib/aws/s3.ts
The path structure supports file deduplication using optional hash prefixes and provides clear organization by course, lesson, and resource type.
Upload Methods
Direct Upload (Server-Side)
lib/aws/s3.ts
Presigned URL Upload (Client-Side)
lib/aws/s3.ts
- API Route
- Client Component
app/api/upload/presigned-url/route.ts
CDN Integration
URL Transformation
The system automatically transforms S3 URLs to CDN URLs:lib/aws/s3.ts
CDN Configuration
- CloudFront
- Azure Front Door
.env.local
- Create CloudFront distribution
- Set S3 bucket as origin
- Enable Origin Access Identity (OAI)
- Configure cache behaviors:
- Videos: Cache for 1 year
- Images: Cache for 1 month
- Documents: Cache for 1 week
Video URL with HLS
For videos, the system automatically prefers HLS manifests:lib/aws/s3.ts
File Validation
File Type Validation
lib/aws/s3.ts
File Size Limits
lib/aws/s3.ts
File Deletion
Delete Single File
lib/aws/s3.ts
Delete Video with HLS
When deleting videos, also delete HLS transcoded files:lib/aws/s3.ts
S3 Bucket Configuration
CORS Policy
S3 Bucket CORS Configuration
Bucket Policy
S3 Bucket Policy
Best Practices
Use Presigned URLs
Use Presigned URLs
Upload large files directly from client to S3 using presigned URLs to avoid server bottlenecks and reduce bandwidth costs.
Enable CDN
Enable CDN
Always use a CDN for production to:
- Reduce latency with edge caching
- Lower S3 data transfer costs
- Improve video streaming performance
Implement File Deduplication
Implement File Deduplication
Use file hashes to prevent duplicate uploads:
Set Lifecycle Policies
Set Lifecycle Policies
Configure S3 lifecycle rules to:
- Delete temp files after 7 days
- Transition old files to Glacier
- Clean up incomplete multipart uploads
Next Steps
Video Processing
Learn about video transcoding with AWS MediaConvert
Authentication
Understand access control for file uploads