コード例 #1
0
        public IActionResult DownloadFile([FromRoute] string filename)
        {
            byte[] fileBytes = ProjectDocumentService.DownloadFile(filename).Result;

            var    provider = new FileExtensionContentTypeProvider();
            string contentType;

            if (!provider.TryGetContentType(filename, out contentType))
            {
                contentType = "application/octet-stream";
            }
            return(new FileContentResult(fileBytes, contentType));
        }