打印预览不能下载问题

optimize
wanghaomei 2 years ago
parent 17eb420f92
commit 464af5d99e

@ -2247,7 +2247,7 @@ namespace Myshipping.Application
fileName = $"{order.MBLNO}_{DateTime.Now.Ticks}";//名称
fileName = $"{order.MBLNO}_{DateTime.Now.Ticks}{fileType}";//名称
var opt = App.GetOptions<TempFileOptions>().Path;
var serverpath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);//服务器路径
if (!Directory.Exists(serverpath))
@ -2528,8 +2528,14 @@ namespace Myshipping.Application
if (File.Exists(fileFullName))
{
_logger.LogInformation($"预览pdf文件{fileFullName}");
var readMem = new ReadOnlyMemory<byte>(File.ReadAllBytes(fileFullName));
_httpContextAccessor.HttpContext.Response.BodyWriter.WriteAsync(readMem);
var sysConfig = _cache.GetAllSysConfig().Result;
var viewUrl = sysConfig.FirstOrDefault(x => x.Code == "booking_print_view_pdf_url");
//var readMem = new ReadOnlyMemory<byte>(File.ReadAllBytes(fileFullName));
//_httpContextAccessor.HttpContext.Response.BodyWriter.WriteAsync(readMem);
_httpContextAccessor.HttpContext.Response.StatusCode = 302;
_httpContextAccessor.HttpContext.Response.Headers["Location"] = $"{viewUrl.Value}{fn}";
}
else
{

Loading…
Cancel
Save