This commit is contained in:
owenchen committed 2026-09-21 16:54:56 +08:00
1 parent 9e79a6a67c
commit 7c8af2fb08
14 files changed
+328 -45

No files matched your search

@@ -23,6 +23,7 @@ namespace CloudBuilder.Security.Policy
public const string LYRIC = "L";
public const string JPG = ".jpg";
public const string M3U8 = ".m3u8";
public static FileTypePolicy instance = null;
@@ -78,7 +79,16 @@ namespace CloudBuilder.Security.Policy
return GetType(value) == LYRIC;
}
public static string PackPicUrl(IApplicationService service, string createdBy, string orderKey)
{
return PackUrl(service, createdBy, orderKey, YesNoPolicy.YES, true);
}
public static string PackUrl(IApplicationService service, string createdBy, string orderKey, string transcodeIndc)
{
return PackUrl(service, createdBy, orderKey, transcodeIndc, false);
}
public static string PackUrl(IApplicationService service, string createdBy, string orderKey, string transcodeIndc, bool isPic)
{
string url = string.Empty;
var webRootPath = service.Configuration[ServiceSettingsPolicy.RequestPath] ?? "";
@@ -114,10 +124,20 @@ namespace CloudBuilder.Security.Policy
{
if (transcodeIndc == YesNoPolicy.YES)
{
var upload = (ServiceSettingsPolicy.GetDmsFileBackupDirectory(service) ?? "").Replace(phy ?? "", "");
var filePathRel = Path.Combine(upload, createdBy, fileExtension.Replace(".", ""), "");
var filePath = filePathRel.Replace(Path.DirectorySeparatorChar, '/') + "/";
url = service.Configuration[AppsettingsPolicy.ApplicationUrl] + webRootPath + filePath + Path.GetFileNameWithoutExtension(orderKey) + JPG + "?v=" + DateTime.Now.ToString("yyyyMMddhhmmss");
if (isPic)
{
var upload = (ServiceSettingsPolicy.GetDmsFileBackupDirectory(service) ?? "").Replace(phy ?? "", "");
var filePathRel = Path.Combine(upload, createdBy, fileExtension.Replace(".", ""), "");
var filePath = filePathRel.Replace(Path.DirectorySeparatorChar, '/') + "/";
url = service.Configuration[AppsettingsPolicy.ApplicationUrl] + webRootPath + filePath + Path.GetFileNameWithoutExtension(orderKey) + JPG + "?v=" + DateTime.Now.ToString("yyyyMMddhhmmss");
}
else
{
var backup = (ServiceSettingsPolicy.GetDmsFileBackupDirectory(service) ?? "").Replace(phy ?? "", "");
var filePathRel = Path.Combine(backup, createdBy, M3U8.Replace(".", ""), "");
var filePath = filePathRel.Replace(Path.DirectorySeparatorChar, '/') + "/";
url = service.Configuration[AppsettingsPolicy.ApplicationUrl] + webRootPath + filePath + Path.GetFileNameWithoutExtension(orderKey) + M3U8;
}
}
else
{
@@ -136,7 +156,7 @@ namespace CloudBuilder.Security.Policy
}
return url;
}
public static string PackSourceVideoUrl(IApplicationService service, string createdBy, string orderKey)
public static string PackSourceVideoUrl(IApplicationService service, string createdBy, string orderKey, string transcodeIndc)
{
var webRootPath = service.Configuration[ServiceSettingsPolicy.RequestPath] ?? "";
var phy = service.Configuration[ServiceSettingsPolicy.PhysicalFileDirectory] ?? "";
@@ -145,8 +165,16 @@ namespace CloudBuilder.Security.Policy
// 使用Path.Combine拼接路径,再将系统分隔符转为URL标准正斜杠
var filePathRel = Path.Combine(upload, createdBy, fileExtension.Replace(".", ""), "");
var filePath = filePathRel.Replace(Path.DirectorySeparatorChar, '/') + "/";
if (YesNoPolicy.IsYes(transcodeIndc))
{
filePathRel = Path.Combine(upload, createdBy, M3U8.Replace(".", ""), "");
}
var filePath = filePathRel.Replace(Path.DirectorySeparatorChar, '/') + "/";
if (YesNoPolicy.IsYes(transcodeIndc))
{
return (service.Configuration[AppsettingsPolicy.ApplicationUrl] ?? "") + webRootPath + filePath + Path.GetFileNameWithoutExtension(orderKey) + M3U8;
}
return (service.Configuration[AppsettingsPolicy.ApplicationUrl] ?? "") + webRootPath + filePath + orderKey;
}