From 3f99d827bce33b0f2e550cfee103964d4ea2d2e7 Mon Sep 17 00:00:00 2001 From: Paul Silvestri Date: Tue, 16 Apr 2024 18:38:25 -0400 Subject: [PATCH] updated stream example --- examples/stream.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/stream.js b/examples/stream.js index 8ae2fca..1e9ebd5 100755 --- a/examples/stream.js +++ b/examples/stream.js @@ -2,7 +2,7 @@ const { PassThrough } = require('stream'); // eslint-disable-next-line import/no-extraneous-dependencies const axios = require('axios'); -const fakeVirusUrl = 'https://secure.eicar.org/eicar_com.txt'; +const fakeVirusUrl = 'https://www.eicar.org/download/eicar-com-2/?wpdmdl=8842&refresh=661ef9d576b211713306069'; // const normalFileUrl = 'https://raw.githubusercontent.com/kylefarris/clamscan/sockets/README.md'; const testUrl = fakeVirusUrl; @@ -19,15 +19,18 @@ async function test() { bypassTest: true, host: 'localhost', port: 3310, - socket: '/var/run/clamd.scan/clamd.sock', + //socket: '/var/run/clamd.scan/clamd.sock', }, }); + // Fetch fake Eicar virus file and pipe it through to our scan screeam const passthrough = new PassThrough(); - const source = axios.get(testUrl); + axios.get( + testUrl, { responseType: 'stream' } + ).then((response) => { + response.data.pipe(passthrough); + }); - // Fetch fake Eicar virus file and pipe it through to our scan screeam - source.pipe(passthrough); try { const { isInfected, viruses } = await clamscan.scanStream(passthrough);