Scan GCP Storage Files for Viruses in C/C++

Implementing a consistent and reliable virus scanning process for your GCP storage files can prevent exposure to the increasing list of threats that are targeting cloud storage. By utilizing the following API in C/C++, you will be able to automatically the scan the contents of a single GCP storage file for viruses, malware, ransomware, spyware, and trojans in less time than it takes to say ‘virus scan’.

To kick things off, we will install libcurl into our C/C++ project:


With the installation out of the way, we are ready to call our virus scan function with the following example code:

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "");
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, "bucketName: <string>");
headers = curl_slist_append(headers, "objectName: <string>");
headers = curl_slist_append(headers, "Content-Type: multipart/form-data");
headers = curl_slist_append(headers, "Apikey: YOUR-API-KEY-HERE");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_mime *mime;
curl_mimepart *part;
mime = curl_mime_init(curl);
part = curl_mime_addpart(mime);
curl_mime_name(part, "jsonCredentialFile");
curl_mime_filedata(part, "/path/to/file");
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
res = curl_easy_perform(curl);

Keep in mind that you will need your GCP bucket name, object name, JSON service account credential file, and API key for a successful response. If you need to obtain an API key, you can do so by registering for a free account on the Cloudmersive website.



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

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