Scan a Google Cloud Platform (GCP) Storage File for Viruses in C#

Modern-day technology is advancing at a very swift pace, but while our technology is evolving, so are the viruses that threaten its use. When you’re storing sensitive data within a GCP storage file, you should also be sure to check that data for any threats. The following API will efficiently scan your file for threats, employing continuous cloud-based updates to ensure the most current virus signatures are scanned for detection.

Let’s get started! First, you need to install the SDK — for this example, we are using .NET Framework, but .NET Core is available as well.

Install-Package Cloudmersive.APIClient.NET.VirusScan -Version 3.0.3

Then, we call the function with the following code:

using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NET.VirusScan.Api;
using Cloudmersive.APIClient.NET.VirusScan.Client;
using Cloudmersive.APIClient.NET.VirusScan.Model;
namespace Example
{
public class ScanCloudStorageScanGcpStorageFileExample
{
public void main()
{
// Configure API key authorization: Apikey
Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");
var apiInstance = new ScanCloudStorageApi();
var bucketName = bucketName_example; // string | Name of the bucket in Google Cloud Storage
var objectName = objectName_example; // string | Name of the object or file in Google Cloud Storage
var jsonCredentialFile = new System.IO.FileStream("C:\\temp\\inputfile", System.IO.FileMode.Open); // System.IO.Stream | Service Account credential for Google Cloud stored in a JSON file.
try
{
// Scan an Google Cloud Platform (GCP) Storage file for viruses
CloudStorageVirusScanResult result = apiInstance.ScanCloudStorageScanGcpStorageFile(bucketName, objectName, jsonCredentialFile);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling ScanCloudStorageApi.ScanCloudStorageScanGcpStorageFile: " + e.Message );
}
}
}
}

Once complete, you will receive a response giving you the virus name (if detected) or giving you the green light that your file is virus-free.

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