Skip to content

Commit

Permalink
updated stream example
Browse files Browse the repository at this point in the history
  • Loading branch information
psilves1 authored and kylefarris committed May 14, 2024
1 parent e5cdbf8 commit 3f99d82
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions examples/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down

0 comments on commit 3f99d82

Please sign in to comment.