Overview
Ecom supports multiple storage drivers for managing uploaded files including product images, user avatars, and digital downloads. Choose between local storage or cloud storage providers for scalability and reliability.Supported Storage Drivers
- Local: Store files on your server
- AWS S3: Amazon Simple Storage Service
- Backblaze B2: Cost-effective S3-compatible storage
- Public: Laravel’s public disk
Configuration
Config File Location
Filesystem Configuration
config/filesystems.php
Local Storage
Configuration
Default configuration stores files in public directory:.env
Benefits
- No additional costs
- Simple setup
- Fast access
- Full control
Limitations
- Limited scalability
- No automatic backups
- Server disk space constraints
- No CDN integration
- Not suitable for multiple servers
Usage
AWS S3 Configuration
Amazon S3 is the industry-standard cloud storage solution.Step 1: Create AWS Account
Sign Up for AWS
Go to AWS Console and create account
Create IAM User
Navigate to IAM → Users → Add User
- User name: ecom-storage
- Access type: Programmatic access
Create S3 Bucket
Navigate to S3 → Create bucket
- Bucket name: your-unique-bucket-name
- Region: Select closest to your users
- Unblock public access (for public files)
Step 2: Configure Environment
.env
Step 3: Install AWS SDK
AWS SDK is already included:composer.json
S3 Regions
Common AWS regions:| Region Code | Region Name |
|---|---|
| us-east-1 | US East (N. Virginia) |
| us-west-2 | US West (Oregon) |
| eu-west-1 | Europe (Ireland) |
| eu-central-1 | Europe (Frankfurt) |
| ap-south-1 | Asia Pacific (Mumbai) |
| ap-southeast-1 | Asia Pacific (Singapore) |
Usage Example
Backblaze B2 Configuration
Backblaze B2 is a cost-effective alternative to AWS S3 with S3-compatible API.Pricing Comparison
| Storage | AWS S3 | Backblaze B2 |
|---|---|---|
| Storage | $0.023/GB | $0.005/GB |
| Download | $0.09/GB | $0.01/GB (free first 3x storage) |
| API Calls | Varies | 2,500 free daily |
Step 1: Create Backblaze Account
Sign Up
Go to Backblaze B2
Create Bucket
Navigate to B2 Cloud Storage → Create a Bucket
- Bucket name: your-bucket-name
- Files in Bucket: Public
- Encryption: Disable (or enable if needed)
Create Application Key
Go to App Keys → Add a New Application Key
- Key Name: ecom-storage
- Allow access to: your-bucket-name
- Permissions: Read and Write
Step 2: Configure Environment
.env
Backblaze Regions
| Region Code | Region Name |
|---|---|
| us-west-001 | US West |
| us-west-002 | US West 2 |
| eu-central-003 | Europe |
Usage Example
File Upload Implementation
Upload Helper Function
Ecom includes upload helper in:Example Upload Controller
Account Deletion with Storage
When deleting user accounts, clean up storage:app/Http/Controllers/Auth/LoginController.php
File Types and Limits
Image Upload Validation
Document Upload Validation
Video Upload Validation
CDN Integration
CloudFront with S3
For better performance, use CloudFront CDN:Configure Settings
- Viewer Protocol Policy: Redirect HTTP to HTTPS
- Allowed HTTP Methods: GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
- Cache Policy: CachingOptimized
Image Optimization
Intervention Image
Ecom uses Intervention Image for manipulation:composer.json
Resize Before Upload
Backup Strategy
Automated Backups
For local storage, implement backups:- S3: Enable versioning in bucket settings
- Backblaze: B2 automatically keeps file versions
Security Best Practices
Private Files
Generating Signed URLs
For private downloads:Cost Optimization
S3 Storage Classes
- Standard: Frequent access
- Intelligent-Tiering: Automatic cost optimization
- Glacier: Archive (slower retrieval)
Lifecycle Policies
Automate file archival:Troubleshooting
Access Denied Error
Access Denied Error
Cause: Incorrect IAM permissions or credentialsSolution:
- Verify AWS credentials in
.env - Check IAM user has S3 permissions
- Ensure bucket policy allows access
- Verify region is correct
Files Not Accessible
Files Not Accessible
Cause: Bucket is private or CORS not configuredSolution:
- Make bucket public or use signed URLs
- Configure CORS policy
- Check CloudFront settings if using CDN
Upload Timeout
Upload Timeout
Cause: Large file or slow connectionSolution:
- Increase PHP
max_execution_time - Increase
upload_max_filesizeandpost_max_size - Use chunked uploads for large files
- Optimize file before upload
High Storage Costs
High Storage Costs
Cause: Many large files or frequent accessSolution:
- Implement image optimization
- Use lifecycle policies for archival
- Delete unused files
- Consider switching to Backblaze B2
- Enable compression
Migration Between Storage Providers
Local to S3 Migration
Performance Optimization
- Use CDN for static assets
- Enable browser caching
- Compress images before upload
- Use lazy loading for images
- Implement progressive image loading
- Cache file URLs
Related Documentation
Media Management
Managing uploaded files
Product Images
Product image handling