Hi! I have create a document library for user to share file (Upload/download). With the security concern I have to scan a file for virus as user upload a file to document library . How do I scan a virus as when user upload a file? I have a metascan on Server. But I don,t know how to send a file for virus scan?
please help!
Thank you Nico Martens for yours information .
As I am new to SP2010 . the process is like this . I have create a document library to upload doc . when the user click on Add document , Is it possible to scan a virus before a doc is uploaded completely ?
Below is a sample of code Metascan that send a Doc to virus scan server.
public boolean sendToMetascan(byte[] fileBytes) throws Exception
{
try
{
String urlString;
String blServerHttp = System.getProperty(“bl_server_http”, “”);
if(WebOSUtils.isEmptyString(blServerHttp)) {
throw new Exception(” Virus scan server cannot be found. File cannot be uploaded.”);
} else {
urlString = “http://” + blServerHttp + UploadedDocument.SCAN_SERVLET_METHOD;
}
if(WebOSUtils.isEmptyString(urlString)) {
throw new Exception(” Virus scan server cannot be found. File cannot be uploaded.”);
} else {
InputStream is = null;
BufferedReader bfReader = null;
StringWriter stringWriter = null;
is = new ByteArrayInputStream(fileBytes);
bfReader = new BufferedReader(new InputStreamReader(is));
stringWriter = new StringWriter();
BrinksCommonUtils.postData(bfReader, urlString, stringWriter, “application/x-www-form-urlencoded”);
stringWriter.flush();
String response = stringWriter.toString();
if ( response.equalsIgnoreCase(“Success”) ) {
return true;
} else if (response.equalsIgnoreCase(“Failure”)) {
return false;
} else if (response.equalsIgnoreCase(“Error”)) {
throw new Exception(” Error in scanning the file. File cannot be uploaded.”);
} else {
return false;
}
}
}
catch (Exception e)
{
throw e;
// return false;
}
}
How do I apply this code to scan a virus when user click on Add document ?
Hi Suttichai,
You should read this article on anti-virus for SharePoint 2013: http://www.harbar.net/archive/2013/02/22/Antivirus-and-SharePoint-2013.aspx
I’m currently using McAfee for SharePoint 2013, which is working great.