|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using Furion;
|
|
|
|
|
using Furion.Logging;
|
|
|
|
|
using Furion.RemoteRequest.Extensions;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Myshipping.Application.ConfigOption;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
@ -29,7 +30,7 @@ namespace Myshipping.Application
|
|
|
|
|
/// <param name="batchNo">批次号</param>
|
|
|
|
|
/// <param name="isLocalTempFile">是否生成本地文件</param>
|
|
|
|
|
/// <param name="attachFileType">附件类型 bcfiles-BC文件</param>
|
|
|
|
|
/// <returns>返沪新的文件路径</returns>
|
|
|
|
|
/// <returns>返回新的文件路径</returns>
|
|
|
|
|
public static async Task<string> MoveFile(string fileDictKey,string sourceFilePath,string batchNo,
|
|
|
|
|
bool isLocalTempFile = false,string attachFileType = "bcfiles")
|
|
|
|
|
{
|
|
|
|
@ -140,5 +141,56 @@ namespace Myshipping.Application
|
|
|
|
|
return bookFilePath;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 暂存Web请求文件暂存
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 暂存Web请求文件暂存
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileDictKey">文件目录KEY</param>
|
|
|
|
|
/// <param name="file">文件</param>
|
|
|
|
|
/// <param name="batchNo">批次号</param>
|
|
|
|
|
/// <param name="attachFileType">附件类型 bcfiles-BC文件</param>
|
|
|
|
|
/// <returns>返回暂存文件路径</returns>
|
|
|
|
|
public static async Task<string> TempSaveWebFile(string fileDictKey, IFormFile file, string batchNo,
|
|
|
|
|
string attachFileType = "bcfiles")
|
|
|
|
|
{
|
|
|
|
|
var logger = Log.CreateLogger(nameof(FileAttachHelper));
|
|
|
|
|
|
|
|
|
|
var opt = App.GetOptions<TempFileOptions>().Path;
|
|
|
|
|
|
|
|
|
|
string filePath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(attachFileType))
|
|
|
|
|
filePath += $"\\{attachFileType}";
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(fileDictKey))
|
|
|
|
|
filePath += $"\\{fileDictKey}";
|
|
|
|
|
|
|
|
|
|
string fileFullName = $"{filePath}\\{file.FileName}";
|
|
|
|
|
|
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
|
|
|
|
{
|
|
|
|
|
filePath = filePath.Replace("\\", "/");
|
|
|
|
|
|
|
|
|
|
fileFullName = fileFullName.Replace("\\", "/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.LogInformation("批次={no} 生成文件保存路径完成 路由={filePath} 服务器系统={system}", batchNo, filePath,
|
|
|
|
|
RuntimeInformation.OSDescription);
|
|
|
|
|
|
|
|
|
|
//预先创建目录
|
|
|
|
|
if (!Directory.Exists(filePath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(filePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (var fileStream = File.Create(fileFullName))
|
|
|
|
|
{
|
|
|
|
|
await file.CopyToAsync(fileStream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fileFullName;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|