AspNetCoreWebApi接口返回文件

 

      [HttpGet]
        public async Task<IActionResult> ShareFile()
        {
             using MemoryStream ms = new MemoryStream();
             //docHtml.Save(ms);//文件流保存
             return File(ms.ToArray(), "application/octet-stream", $"文件名_{DateTime.Now.ToString("yyyy-MM-dd")}.pdf");
        }    

 

posted @ 2022-02-16 15:57  点终将连成线  阅读(355)  评论(0编辑  收藏  举报