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/uploadUpload file(s) with multipart form data
GET
/api/media/:idDownload file by ID
GET
/api/media/:id/thumbnailGet image thumbnail
DELETE
/api/media/:idDelete file
POST
/api/media/watermarkApply watermark to document
POST
/api/media/pdf/generateGenerate PDF from template
POST
/api/media/excel/generateGenerate Excel file from data
Configuration
| Name | Type | Default | Description |
|---|---|---|---|
| PORT | number | 8005 | Service listening port |
| DB_HOST | string | localhost | MSSQL server host |
| UPLOAD_PATH | string | ./uploads | File storage directory |
| MAX_FILE_SIZE | string | 50mb | Maximum upload file size |
| CLAMSCAN_ENABLED | boolean | true | Enable virus scanning |
| RABBITMQ_URIS | string | - | RabbitMQ connection URIs |
Dependencies
No upstream service dependencies — Media is a foundational service consumed by most other services.