if you upload a file into the system using FileUploadStrategyBase and other medium, you might want to scan it for viruses or malicious code. Therefore, in version 10.0.12 and later, an extension point is available so that customers can integrate the file scanning software of their choice into the file upload process. Similar extension points are also available for scanning attachments.
You can use following code to scan your file using Third part service.
the FileUploadResultBase class exposes the delegateScanStream() delegate
public final class Custom_ScanDocuments
{
[SubscribesTo(classStr(FileUploadResultBase), staticDelegateStr(FileUploadResultBase, delegateScanStream))]
public static void FileUploadResultBase_delegateScanStream(System.IO.Stream _stream, EventHandlerRejectResult _validationResult)
{
if (!ScanDocuments::scanStream(_stream))
{
_validationResult.reject();
}
}
private static boolean scanStream(System.IO.Stream _stream)
{
boolean result;
CustomerGoogleSCAN.Setting setting = new
CustomerGoogleSCAN.setting();
CustomerGoogleSCAN.log message = new CustomerGoogleSCAN.log();
setting.applicationName = "Application which you are going to
use";
setting.API = "API key";
CustomerGoogleSCAN.configuration config = new
CustomerGoogleSCAN.configuration();
result = config.scan(setting,_stream,message);
return result;
}
}
I have created sample code in C# and added reference in D365 Project, using following developer document.
https://developers.google.com/api-client-library/dotnet/get_started .
Happy to solve and find new solution
Leave a comment