Exemple #1
0
        public FileTypeDetectionResponse DetermineFileType(byte[] fileBytes)
        {
            if (fileBytes == null)
            {
                throw new ArgumentNullException(nameof(fileBytes));
            }

            var fileType = FileType.Unknown;

            try
            {
                fileType = _glasswallFileOperations.DetermineFileType(fileBytes);

                if (!Enum.IsDefined(typeof(FileType), fileType))
                {
                    _logger.Log(LogLevel.Warning, $"The value of 'fileType' {(int)fileType} is invalid, fallback to {FileType.Unknown}");

                    fileType = FileType.Unknown;
                }
            }
            catch (Exception e)
            {
                _logger.Log(LogLevel.Warning, 0, $"Defaulting 'FileType' to {FileType.Unknown} due to {e.Message}");
            }

            return(new FileTypeDetectionResponse(fileType));
        }
Exemple #2
0
        public FileTypeDetectionResponse DetermineFileType(byte[] fileBytes)
        {
            if (fileBytes == null)
            {
                throw new ArgumentNullException(nameof(fileBytes));
            }
            var fileType = _glasswallFileOperations.DetermineFileType(fileBytes);

            if (!Enum.IsDefined(typeof(FileType), fileType))
            {
                fileType = FileType.Unknown;
            }

            return(new FileTypeDetectionResponse(fileType));
        }
 public FileType DetermineFileType(byte[] fileData)
 {
     return(_glasswallFileOperations.DetermineFileType(fileData));
 }