Skip to main content

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​

MethodEndpointDescription
POST/mediaUpload a file
GET/mediaList media items for the account (paginated)
GET/media/:idGet metadata for a single file
DELETE/media/:idDelete file from S3 and database

Master media endpoints​

MethodEndpointDescription
GET/master/mediaList all media across all accounts
DELETE/master/media/:idDelete any file as a master admin

Upload status​

Each media record tracks its lifecycle:

StatusMeaning
initiatedUpload started, not yet complete
uploadingIn progress
uploadedSuccessfully stored in S3
failedUpload 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