How to virus scan an EXE file in Node.JS
1 min readFeb 28, 2020
Security can be the Achilles’ heel of any project if not handled correctly. Implementation of a good virus scanning system can be a great step in the right direction. Normally this is a very expensive task, either in terms of time or money. Thankfully, that is not the case today. No, today we will be skipping past all of this, straight to the results.
We shall start up by using NPM install to set up our client:
npm install cloudmersive-virus-api-client --save
Once the installation has finished, it’s time to move on to calling our scanFile function, like so:
var CloudmersiveVirusApiClient = require('cloudmersive-virus-api-client');var defaultClient = CloudmersiveVirusApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveVirusApiClient.ScanApi();var inputFile = "/path/to/file"; // File | Input file to perform the operation on.var callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.scanFile(inputFile, callback);
And we are done. Not bad.