Installation
The S3 driver is included by default with Directus via the@directus/storage-driver-s3 package, which uses the AWS SDK v3.
Configuration
Configure S3 storage using environment variables:Configuration Options
string
required
The S3 bucket name where files will be stored.
string
AWS access key ID. If not provided, uses default AWS credential chain (environment variables, IAM roles, etc.).
string
AWS secret access key. Required if
key is provided.string
AWS region where the bucket is located (e.g.,
us-east-1, eu-west-1).string
Optional path prefix for all files within the bucket.
string
Custom S3 endpoint URL for S3-compatible services. Include protocol (http:// or https://).
boolean
Use path-style URLs instead of virtual-hosted-style. Required for some S3-compatible services.
string
Access Control List for uploaded files. Options:
private, public-read, public-read-write, authenticated-read, etc.string
Server-side encryption type:
AES256, aws:kms, or aws:kms:dsse.string
KMS key ID for encryption when using
aws:kms or aws:kms:dsse.number
Connection timeout in milliseconds. Default:
5000.number
Socket timeout in milliseconds. Default:
120000.number
Maximum number of concurrent sockets. Default:
500.boolean
Enable HTTP keep-alive. Default:
true.number
Chunk size for resumable uploads in bytes. Default:
5242880 (5 MiB). Minimum: 5242880 (5 MiB).Examples
Amazon S3
With Root Path
IAM Role (EC2/ECS)
Public Read Access
Server-Side Encryption
KMS Encryption
DigitalOcean Spaces
Cloudflare R2
MinIO
Backblaze B2
Features
Resumable Uploads
The S3 driver supports TUS resumable uploads using S3 multipart upload:- Automatic chunking of large files
- Resume interrupted uploads
- Maximum upload size: 5 TiB
- Maximum parts: 10,000
- Minimum part size: 5 MiB
Multipart Upload
The driver implements S3 multipart upload from/packages/storage-driver-s3/src/index.ts:68-587:
- Uploads are split into chunks
- Chunks are uploaded in parallel (max 60 concurrent)
- Failed parts can be retried independently
- Incomplete uploads can be aborted
Performance Optimization
The driver is optimized for high-concurrency environments from/packages/storage-driver-s3/src/index.ts:89-107:
- Custom connection pool with 500 max sockets (configurable)
- HTTP keep-alive enabled by default
- Configurable timeouts
- Efficient memory usage with streams
Best Practices
IAM Permissions
Minimum required IAM permissions:CORS Configuration
If accessing files directly from the browser:Bucket Lifecycle
Configure lifecycle rules to clean up incomplete multipart uploads:Cost Optimization
- Use S3 Intelligent-Tiering for automatic cost optimization
- Enable S3 Transfer Acceleration for faster uploads from distant regions
- Consider CloudFront CDN for frequently accessed files
- Monitor S3 request costs for high-traffic applications
Troubleshooting
Access Denied Errors
- Verify IAM permissions
- Check bucket policies
- Ensure credentials are correct
- Verify bucket exists in the specified region