/
Scanning uploaded files for viruses
Scanning uploaded files for viruses
private async Task<UploadedDocument> ScanFile(HttpPostedFileBase fileToScan, string modelProperty)
{
WebServiceClient MtoaApi = CreateMtoaApi();
var target = new MemoryStream();
var fileBytes = target.ToArray();
fileToScan.InputStream.CopyTo(target);
string fileExtension = Path.GetExtension(fileToScan.FileName);
bool isInfected = true;
try
{
isInfected = await MtoaApi.VirusScanApi.IsInfected(fileToScan.FileName, fileBytes);
}
catch (Exception ex)
{
throw ex;
}
// Add error when threat exists
if (isInfected)
{
ModelState.AddModelError(modelProperty, ValidationErrors.FileScanError + $" ({fileToScan.FileName})");
return null;
}
return new UploadedDocument {
Name = fileToScan.FileName,
ContentType = fileToScan.ContentType,
Data = fileBytes,
FileNameWithPath = fileToScan.FileName,
FileSize = fileBytes.Length
};
}
, multiple selections available,
Related content
Creating a Service Request with the cost-recovery API
Creating a Service Request with the cost-recovery API
Read with this
CAWIS_TFS14402
CAWIS_TFS14402
More like this
How to implement the "Step Wizard"
How to implement the "Step Wizard"
Read with this
Files for testing various types of attachment in CIVAV Apps
Files for testing various types of attachment in CIVAV Apps
More like this
Integration of .NET 4.X solution with the myTC Account Platform
Integration of .NET 4.X solution with the myTC Account Platform
Read with this
Create, Read, Update, Submit of Service Requests Using NUGET Packages
Create, Read, Update, Submit of Service Requests Using NUGET Packages
More like this