Media Service

NestJS:8005Support

The Media Service handles file uploads, processing, storage, and transformations. It supports image processing, PDF operations, Excel generation, and virus scanning.

Key Features

  • File Upload — Multipart file upload with validation
  • Image Processing — Resize, crop, watermark via JIMP
  • PDF Operations — Generate and manipulate PDFs with pdf-lib and Puppeteer
  • Excel Generation — Create Excel exports with ExcelJS
  • Virus Scanning — ClamScan integration for uploaded files
  • Access Control — Permission-based file access
  • Version Tracking — File version management
  • HTML to PDF — Convert HTML templates to PDF via wkhtmltopdf

API Endpoints

POST
/api/media/upload

Upload file(s) with multipart form data

GET
/api/media/:id

Download file by ID

GET
/api/media/:id/thumbnail

Get image thumbnail

DELETE
/api/media/:id

Delete file

POST
/api/media/watermark

Apply watermark to document

POST
/api/media/pdf/generate

Generate PDF from template

POST
/api/media/excel/generate

Generate Excel file from data

Configuration

NameTypeDefaultDescription
PORTnumber8005Service listening port
DB_HOSTstringlocalhostMSSQL server host
UPLOAD_PATHstring./uploadsFile storage directory
MAX_FILE_SIZEstring50mbMaximum upload file size
CLAMSCAN_ENABLEDbooleantrueEnable virus scanning
RABBITMQ_URISstring-RabbitMQ connection URIs

Dependencies

No upstream service dependencies — Media is a foundational service consumed by most other services.