修改
continuous-integration/drone/push Build is passing

This commit is contained in:
he
2025-11-14 11:41:36 +08:00
parent 1dd8515ac2
commit b6bad061b7
3 changed files with 12 additions and 3 deletions
+8 -2
View File
@@ -143,7 +143,7 @@ public enum ObjectStoreUse
public interface IOSSService
{
public Task<string> UploadToOSSAsync(Stream fileStream, string oosFolderPath, string fileRealName, bool isFileNameAddGuid = true);
public Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true);
public Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true, bool randomFileName = false);
public Task DownLoadFromOSSAsync(string ossRelativePath, string localFilePath);
@@ -322,9 +322,10 @@ public class OSSService : IOSSService
/// <param name="localFilePath"></param>
/// <param name="oosFolderPath"></param>
/// <param name="isFileNameAddGuid"></param>
/// <param name="randomFileName">随机文件名</param>
/// <returns></returns>
/// <exception cref="BusinessValidationFailedException"></exception>
public async Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true)
public async Task<string> UploadToOSSAsync(string localFilePath, string oosFolderPath, bool isFileNameAddGuid = true, bool randomFileName = false)
{
BackBatchGetToken();
@@ -332,6 +333,11 @@ public class OSSService : IOSSService
var ossRelativePath = isFileNameAddGuid ? $"{oosFolderPath}/{Guid.NewGuid()}_{localFileName}" : $"{oosFolderPath}/{localFileName}";
if (randomFileName)
{
var fileExtension = localFileName.Split(".").LastOrDefault();
ossRelativePath = $"{oosFolderPath}/{Guid.NewGuid()}.{fileExtension}";
}
if (ObjectStoreServiceOptions.ObjectStoreUse == "AliyunOSS")
{