Project

General

Profile

Actions

Sub-Task #307

open

Epic #105: Account & Preferences Management

Feature #106: Update profile information

User Story #108: As a user, I want to upload a custom avatar, so that my identity is visually recognizable across the platform.

Avatar storage backends (filesystem and S3)

Sub-Task #307: Avatar storage backends (filesystem and S3)

Added by Bricklou 22 days ago. Updated 20 days ago.

Status:
In Review
Priority:
Normal
Assigned To:
Target version:
Start date:
11/04/2026
Due date:
% Done:

100%

Estimated time:

Description

Technical specification of how avatars are stored and served.

Storage:

  • The server has a blob store with three operations on a key: put, get, delete. A missing file reads as nothing and deleting it is not an error.
  • The backend is chosen by KUBESTRO_STORAGE_BACKEND: fs (default) or s3.
  • fs keeps files under the directory in KUBESTRO_STORAGE_FS_DIR, created when missing.
  • s3 is configured by KUBESTRO_STORAGE_S3_BUCKET, KUBESTRO_STORAGE_S3_ENDPOINT, KUBESTRO_STORAGE_S3_REGION, KUBESTRO_STORAGE_S3_ACCESS_KEY_ID, KUBESTRO_STORAGE_S3_SECRET_ACCESS_KEY and KUBESTRO_STORAGE_S3_PATH_STYLE (for S3-compatible servers such as Garage or MinIO). The bucket must exist.
  • An in-memory store serves the tests.
  • The store is built once at boot and handed to the features that need it. A feature owns a key prefix (avatars/); the storage settings are never read by a feature.
  • A Garage S3 service runs in the dev cluster, with a dev bucket and key prepared by the deploy script.

Data:

  • The database keeps only a pointer on the user: the key of the current avatar and the date it was set.
  • The key is avatars/{user id}/{random id}.webp. The previous object is deleted once the new pointer is stored. A new object is deleted again if its pointer could not be stored.

Images:

  • The server decodes the uploaded image with limits on its size (8192 pixels a side), crops it to a square, and stores a 256x256 WebP. Metadata of the original is not kept. This is a helper shared by every feature that takes an image.
  • Accepted input: PNG, JPG, GIF and WebP, up to 2 MB, sent as the raw body of the request. The dashboard crops and reduces the chosen picture (up to 10 MB) before sending it.

API:

  • PUT /api/v1/me/avatar sets the avatar. DELETE /api/v1/me/avatar removes it.
  • GET /api/v1/users/{id}/avatar returns the image for a signed-in user. The server reads it from the store and answers with an ETag, so the bucket stays private.
  • The user response and the user summaries carry the address of the avatar, versioned by its date.
  • An account that signs in through a login provider cannot change its avatar. Its avatar follows the provider's picture (see the sync sub-task of the read-only user story).

Acceptance criteria:

  • The fs and s3 backends pass the same tests.
  • A file that is not a supported image, or is too large, is refused with a clear error.
  • Replacing or removing an avatar leaves no orphan object in the store.
  • The storage variables are documented.
Actions

Also available in: PDF Atom