Account Management
Avatar Management
Get and upload user avatar
GET
Get Avatar
Endpoints
GET /api/avatar
Retrieves the authenticated user’s avatar image. Supports both local file storage and external URLs.Response
Returns the avatar image file with appropriate content type headers. If avatar is an external URL, returns a 302 redirect.POST /api/avatar
Uploads a new avatar image for the authenticated user. Old avatar is automatically deleted if it was a local file.Request
Image file (multipart/form-data). Maximum size: 2MB. Allowed types: JPEG, PNG, WebP, GIF.
Response
Relative path to the uploaded avatar file
“Avatar uploaded successfully”
Implementation Details
Code Reference
Status Codes
Success
Redirect to external avatar URL (GET only)
No file provided, file too large, or invalid file type
Missing or invalid authentication token
Avatar not found (GET only)
File Requirements
- Maximum size: 2MB
- Allowed formats: JPEG, PNG, WebP, GIF
- Storage: Local file system (user-specific directories)
Example Requests
Get Avatar
Upload Avatar
Environment Variables
Base path for avatar storage (default:
src/avatars)Security Notes
- Old avatars are automatically deleted when uploading new ones
- External URLs are supported (redirects to URL)
- Files are stored in user-specific directories
- Content-Type headers are set based on file extension
- Cache-Control header set to 1 hour for GET requests
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Response
200 - image/*
Avatar image
Get Avatar