Scanning an AWS S3 file for Viruses in Node.JS

Cloudmersive
2 min readJan 7, 2021

Are you storing important data in an AWS S3 file? If so, you want to ensure that data is safe from the growing variety of online threats, and we’ve got something that can do just that. Utilizing the following API in Node.JS, our technology scans for millions of virus signatures, and is continuously refreshed with new signatures via cloud-based updates.

First, you’ll need to install the SDK to utilize the Cloudmersive API:

npm install cloudmersive-virus-api-client --save

Or, add this snippet to your package.json:

  "dependencies": {
"cloudmersive-virus-api-client": "^1.1.7"
}

Gather your parameters from AWS S3 (access key, secret key, bucket region, bucket name, key name) and call the function using the following code:

var CloudmersiveVirusApiClient = require('cloudmersive-virus-api-client');
var defaultClient = CloudmersiveVirusApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveVirusApiClient.ScanCloudStorageApi();var accessKey = "accessKey_example"; // String | AWS S3 access key for the S3 bucket; you can get this from My Security Credentials in the AWS consolevar secretKey = "secretKey_example"; // String | AWS S3 secret key for the S3 bucket; you can get this from My Security Credentials in the AWS consolevar bucketRegion = "bucketRegion_example"; // String | Name of the region of the S3 bucket, such as 'US-East-1'var bucketName = "bucketName_example"; // String | Name of the S3 bucketvar keyName = "keyName_example"; // String | Key name (also called file name) of the file in S3 that you wish to scan for virusesvar callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.scanCloudStorageScanAwsS3File(accessKey, secretKey, bucketRegion, bucketName, keyName, callback);

And in a flash, your result will be delivered! The response will indicate if the file is clean, or identify the virus if one is present.

--

--

Cloudmersive

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