Overview
The Amazon S3 Object Storage module introduces an object storage client that integrates with Amazon S3, providing a clean, abstracted interface for storing and retrieving objects in the cloud. Amazon S3 (Simple Storage Service) is a highly scalable, durable, and secure object storage service for storing and retrieving any amount of data from anywhere.Installation
The IObjectStorage Interface
The module generates anIObjectStorage interface that provides consistent object storage operations:
Configuration
Using AWS Credentials
appsettings.json:Using IAM Roles (Recommended)
For applications running on AWS (EC2, ECS, Lambda): appsettings.json:Using AWS Profile (Local Development)
appsettings.Development.json:Usage Examples
Document Storage Service
Image Upload Service
Backup Service
S3 Key Naming
Best Practices
Use hierarchical structure with forward slashes:AWS SDK Integration
Direct S3 Client Usage
For advanced scenarios, access the S3 client directly:Advanced Features
Pre-Signed URLs
Generate temporary download/upload URLs:Multipart Upload
For large files (>100 MB):Object Metadata
Server-Side Encryption
S3 Storage Classes
Optimize costs with storage classes:| Class | Use Case | Retrieval |
|---|---|---|
| Standard | Frequently accessed | Immediate |
| Intelligent-Tiering | Unknown/changing access | Automatic |
| Standard-IA | Infrequently accessed | Immediate |
| One Zone-IA | Recreatable infrequent data | Immediate |
| Glacier Instant | Archive with instant retrieval | Immediate |
| Glacier Flexible | Archive | Minutes-hours |
| Glacier Deep Archive | Long-term archive | Hours |
Lifecycle Policies
Automate data management:Best Practices
Security
Security
- Use IAM roles instead of access keys
- Enable bucket versioning for critical data
- Encrypt data at rest and in transit
- Implement least privilege access
- Use pre-signed URLs for temporary access
- Enable S3 Block Public Access
Performance
Performance
- Use CloudFront CDN for frequently accessed content
- Implement multipart uploads for large files
- Use Transfer Acceleration for global uploads
- Parallelize operations when possible
- Consider S3 Select for querying data
Cost Optimization
Cost Optimization
- Use appropriate storage classes
- Implement lifecycle policies
- Delete incomplete multipart uploads
- Monitor and analyze access patterns
- Use S3 Intelligent-Tiering for unpredictable workloads
Reliability
Reliability
- Enable versioning for critical buckets
- Implement cross-region replication
- Use S3 Object Lock for compliance
- Monitor with CloudWatch
- Set up event notifications
Monitoring
CloudWatch Metrics
Local Development
LocalStack
Emulate AWS services locally: Docker Compose:MinIO
S3-compatible object storage:Resources
Amazon S3 Documentation
Official AWS documentation
Best Practices
Design and optimization guide
AWS SDK for .NET
.NET SDK reference
S3 Pricing
Cost calculator and pricing
