46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
|
|
|
|
using IRaCIS.Core.Domain.Share;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
namespace IRaCIS.Core.Application.Helper;
|
|
|
|
public static class FileStoreHelper
|
|
{
|
|
|
|
|
|
|
|
public static (string TrustedFileNameForFileStorage, string RealName) GetStoreFileName(string fileName)
|
|
{
|
|
|
|
//带目录层级,需要后端处理前端的路径
|
|
if (fileName.Contains("\\"))
|
|
{
|
|
fileName = fileName.Split("\\").Last();
|
|
}
|
|
|
|
if (fileName.Contains("/"))
|
|
{
|
|
fileName = fileName.Split("/").Last();
|
|
}
|
|
|
|
var trustedFileNameForFileStorage = Guid.NewGuid().ToString() + fileName;
|
|
|
|
return (trustedFileNameForFileStorage, fileName);
|
|
}
|
|
|
|
|
|
public static string GetIRaCISRootDataFolder(IWebHostEnvironment _hostEnvironment)
|
|
{
|
|
var root = (Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\'))).IfNullThrowException().FullName;
|
|
|
|
|
|
var rootFolder =Path.Combine(root, StaticData.IRaCISDataFolder) ;
|
|
|
|
|
|
return rootFolder;
|
|
}
|
|
|
|
}
|
|
|