Skip to main content
PocketBase supports S3-compatible storage backends as an alternative to local filesystem storage. This includes AWS S3, MinIO, DigitalOcean Spaces, Cloudflare R2, and other S3-compatible services.

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
Changing from local to S3 storage (or vice versa) does not automatically migrate existing files. You’ll need to manually copy files between storage backends.

Configuration via code

You can also configure S3 storage programmatically:

Environment variables

For production deployments, use environment variables to avoid hardcoding credentials:
Then read them in your code:

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.com

MinIO

DigitalOcean Spaces

Cloudflare R2

Backblaze B2

Path-style vs. virtual-hosted-style URLs

S3 supports two URL styles:

Virtual-hosted-style (default)

Used by AWS S3, DigitalOcean Spaces, and most modern providers. Set ForcePathStyle: false (or omit, as it’s the default).

Path-style

Required by MinIO and some self-hosted S3 implementations. Set 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:
The internal S3 client supports:
  • ✅ 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:
Never make your bucket publicly readable! PocketBase handles all file access through its API, respecting collection rules and file field protection settings.

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:
This caches files for 30 days while allowing background revalidation.

Troubleshooting

Connection errors

Ensure the endpoint URL is set correctly and includes the protocol (https://).

Authentication errors

Verify your access key and secret key. Check that your IAM user/role has the required permissions.

Path-style errors

Try toggling ForcePathStyle. MinIO requires true, AWS S3 requires false.

Region errors

Ensure the region matches your bucket’s region exactly.

Next steps

File upload

Learn how to upload files to S3 storage

File download

Understand how files are served from S3