Пример #1
0
        public async Task <IActionResult> DownloadFile(string id)
        {
            try
            {
                var file = await _fileLogic.GetFileById(Guid.Parse(id));

                if (file == null)
                {
                    return(NotFound());
                }

                var buffer = await _fileLogic.ReadAsync(file.Path);

                if (buffer == null)
                {
                    return(NotFound());
                }

                return(new FileContentResult(buffer, file.ContentType)
                {
                    FileDownloadName = file.Name
                });
            }
            catch (Exception e)
            {
                return(ExceptionResult(e));
            }
        }