How to virus scan an EXE file in Node.JS

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.

Image for post
Image for post

Written by

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store