修改上传存储路径
This commit is contained in:
@@ -40,10 +40,10 @@ namespace IRaCIS.Core.API.Controllers
|
||||
_userInfo = userInfo;
|
||||
}
|
||||
|
||||
[HttpPost("TrialDocument/UploadTrialDoc/{trialId:guid}/{type}")]
|
||||
[HttpPost("TrialDocument/UploadTrialDoc/{trialId:guid}")]
|
||||
[DisableRequestSizeLimit]
|
||||
[DisableFormValueModelBinding]
|
||||
public async Task<IResponseOutput> UploadTrialDoc(Guid trialId,string type)
|
||||
public async Task<IResponseOutput> UploadTrialDoc(Guid trialId)
|
||||
{
|
||||
var boundary = HeaderUtilities.RemoveQuotes(MediaTypeHeaderValue.Parse(Request.ContentType).Boundary).Value;
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace IRaCIS.Core.API.Controllers
|
||||
if (hasContentDispositionHeader)
|
||||
{
|
||||
|
||||
DealTrialStorePath(trialId, type, contentDisposition.FileName.Value, out string serverFilePath, out string relativePath );
|
||||
DealTrialStorePath(trialId, contentDisposition.FileName.Value, out string serverFilePath, out string relativePath );
|
||||
|
||||
await WriteFileAsync(section.Body, serverFilePath);
|
||||
|
||||
@@ -76,10 +76,10 @@ namespace IRaCIS.Core.API.Controllers
|
||||
}
|
||||
|
||||
|
||||
[HttpPost("TrialDocument/UploadSystemDoc/{type}")]
|
||||
[HttpPost("TrialDocument/UploadSystemDoc")]
|
||||
[DisableRequestSizeLimit]
|
||||
[DisableFormValueModelBinding]
|
||||
public async Task<IResponseOutput> UploadSysTemDoc( string type)
|
||||
public async Task<IResponseOutput> UploadSysTemDoc( )
|
||||
{
|
||||
var boundary = HeaderUtilities.RemoveQuotes(MediaTypeHeaderValue.Parse(Request.ContentType).Boundary).Value;
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace IRaCIS.Core.API.Controllers
|
||||
if (hasContentDispositionHeader)
|
||||
{
|
||||
|
||||
DealSysTemStorePath( type, contentDisposition.FileName.Value, out string serverFilePath, out string relativePath);
|
||||
DealSysTemStorePath( contentDisposition.FileName.Value, out string serverFilePath, out string relativePath);
|
||||
|
||||
await WriteFileAsync(section.Body, serverFilePath);
|
||||
|
||||
@@ -116,10 +116,10 @@ namespace IRaCIS.Core.API.Controllers
|
||||
/// 上传通用文档 比如一致性核查的 比如导出的excel 模板
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CommonDocument/UploadCommonDoc/{fileType}/{moduleType}")]
|
||||
[HttpPost("CommonDocument/UploadCommonDoc")]
|
||||
[DisableRequestSizeLimit]
|
||||
[DisableFormValueModelBinding]
|
||||
public async Task<IResponseOutput> UploadCommonDoc(string fileType, string moduleType)
|
||||
public async Task<IResponseOutput> UploadCommonDoc(/*string fileType, string moduleType*/)
|
||||
{
|
||||
var boundary = HeaderUtilities.RemoveQuotes(MediaTypeHeaderValue.Parse(Request.ContentType).Boundary).Value;
|
||||
|
||||
@@ -134,7 +134,7 @@ namespace IRaCIS.Core.API.Controllers
|
||||
if (hasContentDispositionHeader)
|
||||
{
|
||||
|
||||
DealCommonStorePath(fileType, moduleType, contentDisposition.FileName.Value, out string serverFilePath, out string relativePath);
|
||||
DealCommonStorePath(/*fileType, moduleType,*/ contentDisposition.FileName.Value, out string serverFilePath, out string relativePath);
|
||||
|
||||
await WriteFileAsync(section.Body, serverFilePath);
|
||||
|
||||
@@ -194,21 +194,23 @@ namespace IRaCIS.Core.API.Controllers
|
||||
}
|
||||
|
||||
|
||||
private void DealCommonStorePath(string fileType, string moduleType, string fileRealName, out string serverFilePath, out string relativePath)
|
||||
private void DealCommonStorePath(/*string fileType, string moduleType,*/ string fileRealName, out string serverFilePath, out string relativePath)
|
||||
{
|
||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName;
|
||||
//上传根路径
|
||||
var _fileStorePath = Path.Combine(rootPath, StaticData.CommonFileFolder);
|
||||
var _fileStorePath = Path.Combine(rootPath, StaticData.SystemDataFolder);
|
||||
|
||||
//文件类型路径处理
|
||||
var uploadFolderPath = Path.Combine(_fileStorePath, moduleType, fileType);
|
||||
var uploadFolderPath = Path.Combine(_fileStorePath, StaticData.DataTemplate);
|
||||
if (!Directory.Exists(uploadFolderPath)) Directory.CreateDirectory(uploadFolderPath);
|
||||
|
||||
|
||||
var fileNameEX = Path.GetExtension(fileRealName);
|
||||
var trustedFileNameForFileStorage = Guid.NewGuid().ToString() + fileNameEX;
|
||||
//var fileNameEX = Path.GetExtension(fileRealName);
|
||||
//var trustedFileNameForFileStorage = Guid.NewGuid().ToString() + fileNameEX;
|
||||
|
||||
relativePath = $"/{StaticData.CommonFileFolder}/{moduleType}/{fileType}/{trustedFileNameForFileStorage}";
|
||||
var trustedFileNameForFileStorage = Guid.NewGuid().ToString() + fileRealName;
|
||||
|
||||
relativePath = $"/{StaticData.SystemDataFolder}/{StaticData.DataTemplate}/{trustedFileNameForFileStorage}";
|
||||
|
||||
serverFilePath = Path.Combine(uploadFolderPath, trustedFileNameForFileStorage);
|
||||
}
|
||||
@@ -218,59 +220,64 @@ namespace IRaCIS.Core.API.Controllers
|
||||
{
|
||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName;
|
||||
//上传根路径
|
||||
var _fileStorePath = Path.Combine(rootPath, StaticData.SystemNoticeFolder);
|
||||
var _fileStorePath = Path.Combine(rootPath, StaticData.SystemDataFolder);
|
||||
|
||||
//文件类型路径处理
|
||||
var uploadFolderPath = Path.Combine(_fileStorePath);
|
||||
var uploadFolderPath = Path.Combine(_fileStorePath, StaticData.NoticeAttachment);
|
||||
if (!Directory.Exists(uploadFolderPath)) Directory.CreateDirectory(uploadFolderPath);
|
||||
|
||||
|
||||
var fileNameEX = Path.GetExtension(fileRealName);
|
||||
//var fileNameEX = Path.GetExtension(fileRealName);
|
||||
//var fileName=Path.GetFileName(fileRealName);
|
||||
//var trustedFileNameForFileStorage = fileName + Guid.NewGuid().ToString() + fileNameEX;
|
||||
|
||||
var fileName=Path.GetFileName(fileRealName);
|
||||
var trustedFileNameForFileStorage = fileName + Guid.NewGuid().ToString() + fileNameEX;
|
||||
var trustedFileNameForFileStorage = Guid.NewGuid().ToString() + fileRealName;
|
||||
|
||||
relativePath = $"{StaticData.SystemNoticeFolder}/{trustedFileNameForFileStorage}";
|
||||
relativePath = $"/{StaticData.SystemDataFolder}/{StaticData.NoticeAttachment}/{trustedFileNameForFileStorage}";
|
||||
|
||||
serverFilePath = Path.Combine(uploadFolderPath, trustedFileNameForFileStorage);
|
||||
}
|
||||
|
||||
|
||||
private void DealSysTemStorePath( string type, string fileRealName, out string serverFilePath, out string relativePath)
|
||||
private void DealSysTemStorePath( string fileRealName, out string serverFilePath, out string relativePath)
|
||||
{
|
||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName;
|
||||
//上传根路径
|
||||
var _fileStorePath = Path.Combine(rootPath, StaticData.SystemDataFolder);
|
||||
|
||||
//文件类型路径处理
|
||||
var uploadFolderPath = Path.Combine(_fileStorePath, StaticData.SignDocumentFolder);
|
||||
if (!Directory.Exists(uploadFolderPath)) Directory.CreateDirectory(uploadFolderPath);
|
||||
|
||||
|
||||
//var fileNameEX = Path.GetExtension(fileRealName);
|
||||
//var trustedFileNameForFileStorage = Guid.NewGuid().ToString() + fileNameEX;
|
||||
|
||||
var trustedFileNameForFileStorage = Guid.NewGuid().ToString() + fileRealName;
|
||||
|
||||
relativePath = $"/{StaticData.SystemDataFolder}/{ StaticData.SignDocumentFolder}/{trustedFileNameForFileStorage}";
|
||||
|
||||
serverFilePath = Path.Combine(uploadFolderPath, trustedFileNameForFileStorage);
|
||||
}
|
||||
|
||||
|
||||
private void DealTrialStorePath(Guid trialId,string fileRealName, out string serverFilePath, out string relativePath)
|
||||
{
|
||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName;
|
||||
//上传根路径
|
||||
var _fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder);
|
||||
|
||||
//文件类型路径处理
|
||||
var uploadFolderPath = Path.Combine(_fileStorePath, "SysTemDocument", type);
|
||||
var uploadFolderPath = Path.Combine(_fileStorePath, trialId.ToString(), StaticData.SignDocumentFolder);
|
||||
if (!Directory.Exists(uploadFolderPath)) Directory.CreateDirectory(uploadFolderPath);
|
||||
|
||||
|
||||
var fileNameEX = Path.GetExtension(fileRealName);
|
||||
var trustedFileNameForFileStorage = Guid.NewGuid().ToString() + fileNameEX;
|
||||
//var fileNameEX = Path.GetExtension(fileRealName);
|
||||
//var trustedFileNameForFileStorage = Guid.NewGuid().ToString() + fileNameEX;
|
||||
|
||||
relativePath = $"/{StaticData.TrialDataFolder}/SysTemDocument/{type}/{trustedFileNameForFileStorage}";
|
||||
var trustedFileNameForFileStorage = Guid.NewGuid().ToString() + fileRealName;
|
||||
|
||||
serverFilePath = Path.Combine(uploadFolderPath, trustedFileNameForFileStorage);
|
||||
}
|
||||
|
||||
|
||||
private void DealTrialStorePath(Guid trialId,string type,string fileRealName, out string serverFilePath, out string relativePath)
|
||||
{
|
||||
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName;
|
||||
//上传根路径
|
||||
var _fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder);
|
||||
|
||||
//文件类型路径处理
|
||||
var uploadFolderPath = Path.Combine(_fileStorePath, trialId.ToString(), type);
|
||||
if (!Directory.Exists(uploadFolderPath)) Directory.CreateDirectory(uploadFolderPath);
|
||||
|
||||
|
||||
var fileNameEX = Path.GetExtension(fileRealName);
|
||||
var trustedFileNameForFileStorage = Guid.NewGuid().ToString() + fileNameEX;
|
||||
|
||||
relativePath = $"/{StaticData.TrialDataFolder}/{trialId}/{type}/{trustedFileNameForFileStorage}";
|
||||
relativePath = $"/{StaticData.TrialDataFolder}/{trialId}/{StaticData.SignDocumentFolder}/{trustedFileNameForFileStorage}";
|
||||
|
||||
serverFilePath = Path.Combine(uploadFolderPath, trustedFileNameForFileStorage);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user