Cloud storage¶
At a glance
Move media storage from local disk to a cloud bucket (Azure, Amazon S3, or an S3-compatible service like MinIO or Backblaze B2).
- Time: ~10 minutes
- Who: operators of production deployments
- Prerequisites: a cloud storage account/bucket already created
Cloud-storage support is via django-storages.
How the backend is selected
The active storage backend is wired through Django's STORAGES setting (conf/settings/base.py), which points the default alias at trapper.apps.storage.cloud_storages.TrapperMediaStorage. The DEFAULT_FILE_STORAGE environment variable (amazon_s3 | ovh | azure | unset) selects the concrete cloud engine — the legacy Django DEFAULT_FILE_STORAGE setting was removed in Django 5.1 and is no longer used. Azure deployments must also install azure-storage-blob.
Steps¶
1. Choose a backend and set its variables¶
DEFAULT_FILE_STORAGE=azure
AZURE_ACCOUNT_NAME=trapper
AZURE_ACCOUNT_KEY=key
AZURE_CONTAINER=trapper_data
AZURE_CUSTOM_DOMAIN=trapper.blob.core.windows.net
MEDIA_LOCATION=media
DEFAULT_FILE_STORAGE=amazon_s3
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_STORAGE_BUCKET_NAME=trapper-media
AWS_S3_REGION_NAME=eu-central-1
AWS_S3_ENDPOINT_URL=https://s3.example.com # only for non-AWS S3 (MinIO, Backblaze B2, OVH, …)
Omit AWS_S3_ENDPOINT_URL for real AWS S3 — set it for any S3-compatible provider.
| Field | What it does |
|---|---|
DEFAULT_FILE_STORAGE |
Selects the concrete cloud engine: amazon_s3, ovh, azure, or unset for local disk |
AWS_S3_ENDPOINT_URL |
Override for non-AWS S3-compatible services (MinIO, Backblaze B2, OVH) |
AZURE_CUSTOM_DOMAIN |
The public hostname media URLs are built from |
2. Restart the stack¶
Re-render the profile and restart so the new env values take effect — see Deploy with trapper-setup.
Verify it worked¶
Upload a test resource and confirm the file appears in the bucket/container rather than on local disk. Media URLs served to the browser should point at the cloud domain (AZURE_CUSTOM_DOMAIN or the S3 endpoint), not the Expert Nginx container.
Troubleshooting¶
Azure uploads fail with an import error
Install azure-storage-blob in the Expert image/venv — it isn't a default dependency.
Existing local media isn't migrated automatically
Switching the backend only affects new uploads. Migrating existing files to the new backend is a manual data-migration step, not handled by this flag.