Esempio n. 1
0
        internal async Task <FileData> LoadFileAsync(IDbConnection connection, IGuidGenerator guidGenerator,
                                                     FileRepository fileRepository,
                                                     byte[] binary)
        {
            var fileBytes     = binary;
            var md5HashString = new Md5HashGenerator().CreateMd5HashFromBinary(fileBytes);
            var fileName      = Guid.NewGuid().ToString();
            var fileExtension = this.GetFileExtensionForDataFormat(fileBytes);

            return(await this.GetFileData(connection, guidGenerator, fileRepository, md5HashString, fileBytes, fileName,
                                          fileExtension));
        }
Esempio n. 2
0
        internal async Task <FileData> LoadFileAsync(IDbConnection connection, IGuidGenerator guidGenerator,
                                                     FileRepository fileRepository,
                                                     string filePath)
        {
            var file = new FileInfo(filePath);

            if (!file.Exists)
            {
                throw new FileNotFoundException(filePath);
            }

            var fileBytes     = File.ReadAllBytes(filePath);
            var md5HashString = new Md5HashGenerator().CreateMd5HashFromFile(filePath);
            var fileName      = file.Name;
            var fileExtension = file.Extension;

            return(await this.GetFileData(connection, guidGenerator, fileRepository, md5HashString, fileBytes, fileName,
                                          fileExtension));
        }