Media & File Hosting
The media module handles file uploads, storage, and retrieval for accounts. Files are stored in AWS S3 and metadata is kept in the database. See AWS S3 Setup for configuration.
Upload flow
Client sends file → POST /media
→ Multer buffers the file server-side
→ File streamed to S3
→ Metadata saved (filename, MIME type, size, S3 key)
→ URL returned to client
API endpoints
| Method | Endpoint | Description |
|---|---|---|
POST | /media | Upload a file |
GET | /media | List media items for the account (paginated) |
GET | /media/:id | Get metadata for a single file |
DELETE | /media/:id | Delete file from S3 and database |
Master media endpoints
| Method | Endpoint | Description |
|---|---|---|
GET | /master/media | List all media across all accounts |
DELETE | /master/media/:id | Delete any file as a master admin |
Upload status
Each media record tracks its lifecycle:
| Status | Meaning |
|---|---|
initiated | Upload started, not yet complete |
uploading | In progress |
uploaded | Successfully stored in S3 |
failed | Upload failed |
Content moderation
Uploaded files are scanned with AWS Rekognition on a scheduled basis (MODERATE_MEDIA_CRON) to detect inappropriate content.
Cleanup
The CLEANUP_UNUSED_MEDIA_CRON job runs nightly to remove orphaned S3 objects — files that exist in S3 but no longer have a valid database record.
Configuration
AWS_ACCESS_KEY=your_key
AWS_SECRET_KEY=your_secret
AWS_REGION=us-east-2
AWS_BUCKET_MEDIA_LINKS=your-bucket-name