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

This commit is contained in:
he
2025-03-17 11:21:56 +08:00
parent abeda7820d
commit 78c46572a2
3 changed files with 37 additions and 5 deletions
+19 -2
View File
@@ -545,13 +545,23 @@ public class OSSService : IOSSService
/// <param name="overwrite">是否覆盖已存在的目标文件(默认true</param>
public void MoveObject(string sourcePath, string destPath, bool overwrite = true)
{
GetObjectStoreTempToken();
var aliConfig = ObjectStoreServiceOptions.AliyunOSS;
var client = new OssClient(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? aliConfig.EndPoint : aliConfig.InternalEndpoint, AliyunOSSTempToken.AccessKeyId, AliyunOSSTempToken.AccessKeySecret, AliyunOSSTempToken.SecurityToken);
if (sourcePath.StartsWith("/"))
{
sourcePath = sourcePath.Substring(1);
}
if (destPath.StartsWith("/"))
{
destPath = destPath.Substring(1);
}
var sourceBucket = aliConfig.BucketName;
var sourceKey = sourcePath;
@@ -565,9 +575,16 @@ public class OSSService : IOSSService
// 检查目标是否存在(当不允许覆盖时)
if (!overwrite && client.DoesObjectExist(destBucket, destKey))
{
throw new InvalidOperationException("File exist");
throw new InvalidOperationException("File Exist");
}
//var copyRequest = new Aliyun.OSS.CopyObjectRequest(sourceBucket, sourceKey, sourceBucket, destKey);
//var result = client.CopyObject(copyRequest);
//// 2. 删除原文件(可选,根据是否需要保留原文件)
//client.DeleteObject(sourceBucket, sourceKey);
// 执行复制
var copyRequest = new Aliyun.OSS.CopyObjectRequest(
sourceBucket, sourceKey,