The Media domain handles image uploads and optimization for MinMaxHub. Users upload images via presigned URLs, and an asynchronous pipeline converts them to optimized WebP format.
How Uploads Work
Uploading an image is a two-step process:
1. Get a Presigned URL
Call the presign endpoint with the desired file key and content type. The API returns:
uploadUrl-- a temporary signed URL for uploading the file directly to storage.mediaUrl-- the permanent public URL where the image will be accessible.
2. Upload the File
PUT the image file directly to the uploadUrl. After upload, an asynchronous optimization pipeline converts the image to WebP format (capped at 2000px on the longest side). The mediaUrl remains the same -- once optimization completes, it serves the optimized version.
Supported Contexts
Images can be uploaded for three contexts:
| Context | Key Pattern | Example |
|---|---|---|
| User avatars | users/{userId}/avatar.webp | Profile pictures |
| Entity hero images | entities/{entityId}/hero.webp | Page cover images |
| Node cover images | nodes/{nodeId}/cover.webp | Category images |
All upload keys must end in .webp.
Accepted File Types
image/jpegimage/pngimage/webp
Maximum file size: 5 MB (enforced client-side).
Presign Request
Code
Presign Response
Code
The presigned upload URL expires after 15 minutes.
API Endpoints
| Method | Endpoint | Purpose | Auth |
|---|---|---|---|
POST | /media/presign | Get a presigned upload URL | Required |
Last modified on