Media Upload Flow
Signed URLs, validation, CDN publishing, and storage ownership.
Flow
- Client requests signed upload URL from API.
- API validates user permissions and file policy (type, size).
- Client uploads directly to S3 via signed URL.
- S3 event triggers worker for virus scan and optimization.
- CDN publishes optimized asset; API updates record status.
Request signed URL
curl -X POST "$API_URL/v1/media/upload-url" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"filename":"photo.jpg","contentType":"image/jpeg","sizeBytes":204800}'Response
{
"uploadUrl": "https://s3.amazonaws.com/bucket/key?X-Amz-Signature=...",
"mediaId": "med_01HZ...",
"expiresAt": "2026-05-24T19:00:00Z"
}File policy
| Type | Max size | Allowed MIME |
|---|---|---|
| Image | 10 MB | image/jpeg, image/png, image/webp |
| Document | 25 MB | application/pdf |
| Video | 500 MB | video/mp4 |