Scan AWS S3 Bucket for Viruses in C/C++
With cyber threats constantly on the rise, it’s becoming more and more difficult to sufficiently protect your content from viruses, malware, ransomware, and the vast array of other malicious attacks. Cloud storage services, such as AWS S3, have seen an uptick in the amount of cyberattacks targeting content that businesses have entrusted into the file. One way you can guard against these threats is by utilizing the following API to automatically scan an AWS S3 file for viruses in C/C++. The operation supports several file formats and provides immediate results.
Let’s start by installing libcurl into our project:
libcurl/7.75.0
After the installation, we are ready to call the virus scan function with the following code:
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.cloudmersive.com/virus/scan/cloud-storage/aws-s3/single");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "accessKey: <string>");
headers = curl_slist_append(headers, "secretKey: <string>");
headers = curl_slist_append(headers, "bucketRegion: <string>");
headers = curl_slist_append(headers, "bucketName: <string>");
headers = curl_slist_append(headers, "keyName: <string>");
headers = curl_slist_append(headers, "Apikey: YOUR-API-KEY-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
This simple process will deliver your results in no time at all! In order for the process to work, be sure to have your AWS S3 access key, secret key, bucket region, bucket name, key name, and API key handy to plug in. To retrieve your free API key, visit the Cloudmersive website; this will give you access to 800 calls/month across our entire API library.