[HttpGet("DownloadTemplate")]
[AllowAnonymous]
public async Task<dynamic> DownloadTemplate([FromQuery] EnumBackgroundConfig Config)
{
if (!Enum.IsDefined(typeof(EnumBackgroundConfig), (int)Config))
{
return Content("请求参数有误! ");
}
string EnumStr = Enum.GetName(typeof(EnumBackgroundConfig), (int)Config);
if (string.IsNullOrEmpty(EnumStr))
{
return Content("请求参数有误! ");
}
var dir = $"{AppContext.BaseDirectory}TempFiles\\DownloadTemplate\\{EnumStr}.xlsx";
dir = Freed.Common.Helpers.Utils.GetRuntimeDirectory(dir);
if (!System.IO.File.Exists(dir))
return Content("模板文件不存在! ");
var ms = await System.IO.File.ReadAllBytesAsync(dir);
return File(ms, "application/octet-stream", System.Web.HttpUtility.UrlEncode(EnumStr + ".xlsx"));
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交