https://zhuanlan.zhihu.com/p/35053877
文件下载
找到指定的文件,转换成流,通过.net core自带的File
方法返回流文件,完成文件下载:
[HttpGet("download")]
public async Task<IActionResult> Get(string fileName)
{
try
{
var addrUrl = Path.Combine(Directory.GetCurrentDirectory(), BASEFILE, $@"{fileName}");
FileStream fs = new FileStream(addrUrl, FileMode.Open);
return File(fs, "application/vnd.android.package-archive", fileName);
}
catch(Exception ex)
{
return NotFound();
}
}