public IActionResult Download(Guid id)
        {
            var fileEntry = _dispatcher.Dispatch(new GetEntityByIdQuery <FileEntry> {
                Id = id
            });
            var content = _fileManager.Read(fileEntry);

            return(File(content, MediaTypeNames.Application.Octet, WebUtility.HtmlEncode(fileEntry.FileName)));
        }
        public IActionResult Download(Guid id)
        {
            var fileEntry = _fileEntryService.GetById(id);
            var content   = _fileManager.Read(fileEntry);

            return(File(content, MediaTypeNames.Application.Octet, WebUtility.HtmlEncode(fileEntry.FileName)));
        }
Exemple #3
0
        public IActionResult Download(Guid id)
        {
            var fileEntry = _dispatcher.Dispatch(new GetEntityByIdQuery <FileEntry> {
                Id = id
            });

            var rawData = _fileManager.Read(fileEntry.ToFileEntryDTO());
            var content = fileEntry.Encrypted && fileEntry.FileLocation != "Fake.txt"
                ? rawData
                          .UseAES(fileEntry.EncryptionKey.FromBase64String())
                          .WithCipher(CipherMode.ECB)
                          .WithPadding(PaddingMode.PKCS7)
                          .Decrypt()
                : rawData;

            return(File(content, MediaTypeNames.Application.Octet, WebUtility.HtmlEncode(fileEntry.FileName)));
        }