Why use S3 storage
S3-compatible storage provides several advantages:- Scalability - Handle unlimited file storage without disk space concerns
- Reliability - Built-in redundancy and durability (99.999999999% for AWS S3)
- Performance - Geographic distribution and CDN integration
- Cost efficiency - Pay only for what you use, with automatic scaling
- Backups - Easy replication across regions
Storage backend selection
PocketBase automatically selects the storage backend based on your settings:Configuration via Admin UI
The easiest way to configure S3 storage is through the PocketBase Admin UI:1
Navigate to Settings
Go to Settings > Files storage in the Admin UI
2
Enable S3 storage
Toggle “Use S3 storage” to enable it
3
Enter S3 credentials
Fill in your S3 bucket configuration:
- Bucket name
- Region
- Endpoint
- Access key
- Secret key
- Force path style (if required)
4
Test connection
Use the “Test” button to verify your configuration
5
Save settings
Click “Save” to apply the configuration
Configuration via code
You can also configure S3 storage programmatically:Environment variables
For production deployments, use environment variables to avoid hardcoding credentials:Provider-specific configurations
AWS S3
For AWS S3, you can omit the endpoint - it will be constructed automatically from the region:
https://s3.{region}.amazonaws.comMinIO
DigitalOcean Spaces
Cloudflare R2
Backblaze B2
Path-style vs. virtual-hosted-style URLs
S3 supports two URL styles:Virtual-hosted-style (default)
ForcePathStyle: false (or omit, as it’s the default).
Path-style
ForcePathStyle: true.
AWS S3 deprecated path-style URLs for buckets created after September 30, 2020. Use virtual-hosted-style for AWS S3.
Direct S3 filesystem creation
For advanced use cases, you can create S3 filesystem instances directly:Using the S3 filesystem
S3 implementation details
PocketBase uses a custom S3 implementation (not AWS SDK) for minimal dependencies:- ✅ GetObject - Download files
- ✅ HeadObject - Get file metadata
- ✅ PutObject - Upload files
- ✅ DeleteObject - Delete files
- ✅ CopyObject - Copy files
- ✅ ListObjects - List files with pagination
- ✅ Multipart uploads - For large files
- ✅ AWS Signature V4 - Authentication
Bucket permissions
Your S3 bucket needs the following permissions:CORS configuration
If you’re accessing files directly from the browser, configure CORS on your bucket:CORS is only needed if you’re serving files directly from S3. When using PocketBase’s API endpoint, CORS is handled by PocketBase.
Migration between storage backends
To migrate files from local to S3 (or vice versa):Performance considerations
Multipart uploads
For files larger than 5MB, PocketBase automatically uses multipart uploads:Concurrent operations
The S3 driver supports concurrent operations:Caching
PocketBase sets aggressive cache headers for S3 files:Troubleshooting
Connection errors
https://).
Authentication errors
Path-style errors
ForcePathStyle. MinIO requires true, AWS S3 requires false.
Region errors
Next steps
File upload
Learn how to upload files to S3 storage
File download
Understand how files are served from S3