Object Storage#
Profile pictures are stored in S3-compatible object storage, not in PostgreSQL or on local disk.
The user_account.avatar column holds only the file metadata (object key, content type, size);
the image bytes live in the bucket.
Storage is optional. Until it is configured, the application starts normally, the avatar endpoints
answer 503 Service Unavailable, and GET /api/config/auth reports avatarUploadsEnabled: false
so the SPA hides the upload controls.
Configuration#
Storage turns on only when STORAGE_S3_ENDPOINT, STORAGE_S3_BUCKET, STORAGE_S3_ACCESS_KEY,
and STORAGE_S3_SECRET_KEY are all set. None of them has a default.
Variable |
Purpose |
Default |
|---|---|---|
|
S3 API endpoint URL |
(unset) |
|
Bucket name |
(unset) |
|
Access key ID |
(unset) |
|
Secret access key |
(unset) |
|
Signing region |
|
|
Allow a plain |
|
|
Address the bucket as |
|
Local Development#
make start-infra starts a RustFS container alongside PostgreSQL and a
one-shot storage-init container that creates the uploads bucket (re-running it is harmless).
S3 API:
http://localhost:19000Web console:
http://localhost:19001(app/app)
.env.local.example already contains matching values:
STORAGE_S3_ENDPOINT=http://localhost:19000
STORAGE_S3_ACCESS_KEY=app
STORAGE_S3_SECRET_KEY=app
STORAGE_S3_BUCKET=uploads
STORAGE_S3_REGION=us-east-1
STORAGE_S3_ALLOW_HTTP=true
STORAGE_S3_VIRTUAL_HOSTED_STYLE=false
To create the bucket again by hand:
docker compose -f tools/deploy/docker/docker-compose.infra.yml run --rm storage-init
The integration tests start their own RustFS container through pytest-databases and need no
local configuration.
Production#
Point the same variables at any S3-compatible provider and leave STORAGE_S3_ALLOW_HTTP off.
Railway buckets map directly onto these variables: copy (or reference) the bucket’s endpoint,
bucket name, access key ID, and secret access key into STORAGE_S3_ENDPOINT,
STORAGE_S3_BUCKET, STORAGE_S3_ACCESS_KEY, and STORAGE_S3_SECRET_KEY on the app service.
Railway buckets use virtual-hosted-style addressing, so also set:
STORAGE_S3_REGION=auto
STORAGE_S3_VIRTUAL_HOSTED_STYLE=true
For AWS S3, use the regional endpoint (for example https://s3.us-east-1.amazonaws.com) and the
bucket’s region.
How Avatars Are Stored#
POST /api/me/avataraccepts a multipartfilefield up to 5 MB. Requests larger than that (plus a small multipart allowance) are refused with413before the body is buffered.The image type is detected from its leading bytes; only JPEG, PNG, GIF, and WebP are accepted. SVG and anything else is refused with
400. The client filename andContent-Typeare ignored.Objects are written under a server-generated key,
avatars/<user id>/<random hex>.<ext>.The image is uploaded before the database row is committed. Replacing or removing an avatar, or deleting the account, deletes the previous object after the commit succeeds.
GET /api/me/avatarserves the bytes with the stored content type,Cache-Control: private, no-cache, andX-Content-Type-Options: nosniff. TheavatarUrlreturned on the user profile carries a per-upload?v=value, so a new picture shows up at once.