private static void ScanFile(string apiUrl, string file) { MetadefenderCoreClient metadefenderCoreClient = new MetadefenderCoreClient(apiUrl); // This is optional: using custom HttpConnector metadefenderCoreClient.SetHttpConnector(new CustomHttpConnector()); try { Stream inputStream = File.Open(file, FileMode.Open); string dataId = metadefenderCoreClient.ScanFile(inputStream, new FileScanOptions().SetFileName(GetFileNameFromPath(file))); Console.WriteLine("File scan started. The data id is: " + dataId); } catch (MetadefenderClientException e) { Console.WriteLine("Error during file scan: " + e.GetDetailedMessage()); } catch (FileNotFoundException e) { Console.WriteLine("File not found: " + file + " Exception: " + e.Message); } }
private static void ShowApiInfo(string apiUrl, string apiUser, string apiUserPass) { MetadefenderCoreClient metadefenderCoreClient; try { metadefenderCoreClient = new MetadefenderCoreClient(apiUrl, apiUser, apiUserPass); metadefenderCoreClient.SetHttpConnector(new CustomHttpConnector()); Console.WriteLine("Metadefender client created. Session id is: " + metadefenderCoreClient.GetSessionId()); } catch (MetadefenderClientException e) { Console.WriteLine("Cannot login to this API. Error message: " + e.GetDetailedMessage()); return; } try { License license = metadefenderCoreClient.GetCurrentLicenseInformation(); Console.WriteLine("Licensed to: " + license.licensed_to); } catch (MetadefenderClientException e) { Console.WriteLine("Cannot get license details: " + e.GetDetailedMessage()); } try { List <EngineVersion> result = metadefenderCoreClient.GetEngineVersions(); Console.WriteLine("Fetched engine/database versions: " + result.Count); } catch (MetadefenderClientException e) { Console.WriteLine("Cannot get engine/database versions: " + e.GetDetailedMessage()); } try { ApiVersion apiVersion = metadefenderCoreClient.GetVersion(); Console.WriteLine("Api endpoint apiVersion: " + apiVersion.version); } catch (MetadefenderClientException e) { Console.WriteLine("Cannot get api endpoint version: " + e.GetDetailedMessage()); } try { List <ScanRule> scanRules = metadefenderCoreClient.GetAvailableScanRules(); Console.WriteLine("Available scan rules: " + scanRules.Count); } catch (MetadefenderClientException e) { Console.WriteLine("Cannot get available scan rules: " + e.GetDetailedMessage()); } try { metadefenderCoreClient.Logout(); Console.WriteLine("Client successfully logged out."); } catch (MetadefenderClientException e) { Console.WriteLine("Cannot log out: " + e.GetDetailedMessage()); } }