Scan an AWS S3 Bucket for Viruses in Go

If you utilize AWS S3 to store valuable files and content for your company, adding an extra level of security beyond your basic firewall can be a smart move. Cloud storage files are regularly the target for cybercrimes, and one infected file can trigger a domino effect through your system. By running the following API in Go, you can check a single AWS S3 file (and its contents) for multiple types of threats, including viruses, malware, trojans, ransomware, and spyware. The database referenced by the operation contains over 17 million virus signatures, and is continuously updated via the cloud.

In order to call the virus scan function, all you need to do is input the AWS S3 access key, secret key, bucket region, bucket name, and key name into the following code:

package mainimport (
"fmt"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/virus/scan/cloud-storage/aws-s3/single"
method := "POST"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("accessKey", "<string>")
req.Header.Add("secretKey", "<string>")
req.Header.Add("bucketRegion", "<string>")
req.Header.Add("bucketName", "<string>")
req.Header.Add("keyName", "<string>")
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}

That’s it! To retrieve your API key, head to the Cloudmersive website to register for a free account; this will give you access to 800 monthly calls across our entire library of 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