feat(ClamAvService): Add support for enhanced streaming methods in ClamAvService
This commit is contained in:
parent
6adfcc2201
commit
a2d8d1cbfd
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-02-05 - 1.3.0 - feat(ClamAvService)
|
||||
Add support for enhanced streaming methods in ClamAvService
|
||||
|
||||
- Add methods to ClamAvService: scanStream for NodeJS streams, scanWebStream for Web API streams, and scanFileFromWebAsStream for fetching and scanning files from URLs.
|
||||
- Update usage examples in readme for new streaming methods.
|
||||
|
||||
## 2025-02-05 - 1.2.0 - feat(ClamAvService)
|
||||
Add stream scanning methods to ClamAvService
|
||||
|
||||
|
20
readme.md
20
readme.md
@ -96,10 +96,11 @@ main().catch(console.error);
|
||||
|
||||
### Streaming Scanning
|
||||
|
||||
The `ClamAvService` now also supports scanning streams directly using two new methods:
|
||||
The `ClamAvService` supports scanning both NodeJS streams and Web API streams using three specialized methods:
|
||||
|
||||
- `scanStream(stream: NodeJS.ReadableStream)`: Scans a NodeJS stream (local file streams, network streams, etc.)
|
||||
- `scanWebStream(url: string)`: Fetches a web resource as a stream and scans it
|
||||
- `scanStream(stream: NodeJS.ReadableStream)`: Scans any NodeJS readable stream (files, network, etc.)
|
||||
- `scanWebStream(webstream: ReadableStream)`: Scans a Web API ReadableStream
|
||||
- `scanFileFromWebAsStream(url: string)`: Fetches and scans a file from a URL using NodeJS http/https
|
||||
|
||||
#### Example Usage
|
||||
|
||||
@ -110,14 +111,21 @@ import { createReadStream } from 'fs';
|
||||
async function main() {
|
||||
const clamService = new ClamAvService('127.0.0.1', 3310);
|
||||
|
||||
// Example 1: Scanning a local file stream
|
||||
// Example 1: Scanning a local file stream (NodeJS)
|
||||
const fileStream = createReadStream('path/to/local/file');
|
||||
const streamResult = await clamService.scanStream(fileStream);
|
||||
console.log('Stream Scan Result:', streamResult);
|
||||
|
||||
// Example 2: Scanning a web resource
|
||||
const webResult = await clamService.scanWebStream('http://example.com/file');
|
||||
// Example 2: Scanning a web resource using NodeJS http/https
|
||||
const webResult = await clamService.scanFileFromWebAsStream('http://example.com/file');
|
||||
console.log('Web Stream Scan Result:', webResult);
|
||||
|
||||
// Example 3: Scanning a Web API ReadableStream
|
||||
const response = await fetch('http://example.com/file');
|
||||
if (response.body) {
|
||||
const webStreamResult = await clamService.scanWebStream(response.body);
|
||||
console.log('Web Stream API Scan Result:', webStreamResult);
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartantivirus',
|
||||
version: '1.2.0',
|
||||
version: '1.3.0',
|
||||
description: 'A Node.js package for integrating antivirus scanning capabilities using ClamAV, allowing in-memory file and data scanning.'
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user