node-clamav-file-scanner
v1.0.3
Published
A simple and efficient Node.js utility for sanitizing and scanning uploaded files using ClamAV.
Maintainers
Readme
🛡️ Node ClamAV File Scanner
A simple and efficient Node.js utility for sanitizing and scanning uploaded files using ClamAV.
Features
- Sanitization: Clean files (SVG, PDF, JPEG) before scanning.
- Virus Scanning: Leverages ClamAV for virus detection.
- Easy Integration: Simple API for quick setup.
Installation
npm install node-clamav-file-scannerUsage
- Initialize ClamAV Scanner
const { initClamavScanner, scanFile } = require('node-clamav-file-scanner');
initClamavScanner({
host: '127.0.0.1', // ClamAV server host
port: 3310, // ClamAV server port
timeout: 50000, // Timeout in ms
});
- Scan Files
try {
await scanFile(file, true); // 'true' to enable sanitization
console.log('File is clean!');
} catch (error) {
console.error('Error scanning file:', error.message);
}scanFile Parameters
file: The file object with properties path, originalname, and mimetype.
sanitizeFlag: (Optional) If true, sanitizes before scanning.
