Media Storage
We currently have 2 storage types that you can use.
File storage
S3 storage
This can be set through the STORAGE_TYPE
environment variable. There are corresponding env that you can set to configure that storage type. S3 for example:
STORAGE_S3_BUCKET=
STORAGE_S3_REGION=
STORAGE_S3_ENDPOINT=
STORAGE_S3_ACCESS_KEY_ID=
STORAGE_S3_SECRET_ACCESS_KEY=
Storage Proxy
The URL of the media will always be pointing to your-url.com/media/data/[file].
As such, you could serve the media through any methods by resolving that URL. It may be useful to hook it up to a CDN like Cloudflare to reduce unnecessary server load. In practice, you could set a redirect from that URL to another subdomain in Cloudflare to get granular access of what you serve.
We also provide the STORAGE_PROXY
env variable. This setting controls whether you want the server to serve the media on the path mentioned above.
When STORAGE_PROXY
is local, it will serve the static files in the server. This only works if STORAGE_TYPE
is file.
You could also set STORAGE_PROXY
to any URL. This will in turn proxy the request to the specified URL.
Alternatively, pass any other value and the proxy will be disabled.
Changing between storage type
We currently do not have any mechanism to handle changing between storage types. Changing how the server handles it is just a simple envvar change. However, you'll need to migrate the data between storage type manually.
Serving media yourself
Cloudflare
Cache
CORS
Last updated