This project provides a file storage service with integrated antivirus scanning, authorization, and preview generation. It is designed for use in secure environments and supports integration with external services such as S3-compatible storage, antivirus servers, and authorization APIs.
- File Upload & Download: Securely upload and download files.
- Antivirus Integration: Files with Preview are scanned for viruses before being stored.
- Authorization: Access is controlled via an external authorization API.
- Preview Generation: Supports generating previews for supported file types. It needs ImageMagick installed on the system.
- Logging: Detailed logging for debugging and auditing.
- RabbitMQ Integration: For asynchronous processing and notifications.
- MongoDB Support: Stores file metadata.
Configuration is managed via the .env file. Key variables include:
| Variable | Description |
|---|---|
| ENABLE_FILE_SECURITY_CHECK | Enable antivirus scanning |
| ANTIVIRUS_SERVICE_HOSTNAME | Antivirus server hostname |
| ANTIVIRUS_SERVICE_PORT | Antivirus server port |
| FILE_STORAGE_SERVICE_URL | Base URL for the file storage service |
| FILES_STORAGE_USE_STREAM_TO_ANTIVIRUS | Use streaming for antivirus checks |
| AUTHORIZATION_API_URL | URL of the authorization API |
| LOGGER_LOG_LEVEL | Logging level (e.g., debug, info, warn) |
| RABBITMQ_URI | RabbitMQ connection URI |
| DB_URL | MongoDB connection URI |
| DB_DEBUG | Enable MongoDB debug logging |
| PREVIEW_PRODUCER_INCOMING_REQUEST_TIMEOUT | Timeout for preview generation requests |
| CORE_INCOMING_REQUEST_TIMEOUT_MS | Core service request timeout (ms) |
| INCOMING_REQUEST_TIMEOUT_COPY_API_MS | Timeout for copy API requests (ms) |
- Node.js (v18+ recommended)
- npm
- MongoDB
- RabbitMQ
- S3-compatible storage (e.g., AWS S3, MinIO)
- Antivirus server (e.g., ClamAV)
-
Clone the repository:
git clone <repository-url> cd file-storage
-
Install dependencies:
npm ci
-
Configure environment:
- Copy
.env.defaultto.envand adjust values as needed.
- Copy
-
Start the service:
npm run start:files-storage:dev
npm run testsrc/- Main source codetesting/- Testing utilities and mocksshared/- Shared utilities and typesmodules/- Domain modules (file storage, etc.)infra/- Infrastructure (S3 client, authorization, configuration, antivirus client)
.env- Environment configuration