public async Task <IActionResult> DownloadFileReport(long idCompany, [FromRoute(Name = "idFile")] long idFile) { try { var fileEntity = await _filesRepository.ById(idFile); if (fileEntity != null) { var stream = System.IO.File.ReadAllBytes(fileEntity.Uri); HttpContext.Response.ContentType = "application/pdf"; var response = new FileContentResult(stream, fileEntity.Mime) { FileDownloadName = fileEntity.Name }; return(response); } else { return(StatusCode(500)); } } catch (Exception e) { return(new ObjectResult(new { message = e.Message }) { StatusCode = 500 }); } }