Protection Engine for Cloud Services

 View Only

ScanEngine's performance when scanning a large file (~1-2GB)

  • 1.  ScanEngine's performance when scanning a large file (~1-2GB)

    Posted Feb 07, 2020 01:48 PM

    I'm having issues with ScanEngine when I send a file that is about 1-2 GBs in size. I'm using the following code in C#, as per the documentation:

                var requestManager = new ScanRequestManager();
                requestManager.PrepareForScan(new List<ScanEngineInfo> { new ScanEngine(HOST, PORT) }, TIMEOUT, 20);

                try
                {
                    var streamScanRequest = requestManager.CreateStreamScanRequest(Policy.SCAN);
                    var binaryReader = new BinaryReader(fileStream);

                    streamScanRequest.Start(filename, null);
                    var chunk = binaryReader.ReadBytes(CHUNK_SIZE);
                    while (chunk.Length > 0)
                    {
                        streamScanRequest.Send(chunk);
                        chunk = binaryReader.ReadBytes(CHUNK_SIZE);
                    }

                    var scanResult = streamScanRequest.Finish(Stream.Null);
                    return scanResult.fileStatus;
                }
                catch (ScanException ex)
                {
                    // Logging
                    return FileScanStatus.SCANNING_PROBLEM;
                }
                catch (Exception ex)
                {
                    // Logging
                    return FileScanStatus.SCANNING_PROBLEM;

                }

    This can take about 10-20 minutes for the while loop to finish and even more time for the Finish() function to return a result. It usually hangs.

    What's the best approach when dealing with such large files? Compressing them? Is there another API for this sort of situation?

    Thank you