Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoha Jin <soha@lohu.info>2021-09-09 13:23:22 +0300
committerSoha Jin <soha@lohu.info>2021-09-09 13:23:22 +0300
commit3487365d56642aa11ffda336ce7d9165a1157c75 (patch)
tree60e64e242479e8454189b65b69edfcd9a3aa8764 /Duplicati/Library
parentb9aad24deb4a4c88bb284bce3a6ee64e1939ce9e (diff)
Tencent COS: support setting storage class
Diffstat (limited to 'Duplicati/Library')
-rw-r--r--Duplicati/Library/Backend/TencentCOS/COSBackend.cs29
-rw-r--r--Duplicati/Library/Backend/TencentCOS/Strings.cs3
2 files changed, 25 insertions, 7 deletions
diff --git a/Duplicati/Library/Backend/TencentCOS/COSBackend.cs b/Duplicati/Library/Backend/TencentCOS/COSBackend.cs
index 5951c50b3..249999fa8 100644
--- a/Duplicati/Library/Backend/TencentCOS/COSBackend.cs
+++ b/Duplicati/Library/Backend/TencentCOS/COSBackend.cs
@@ -29,6 +29,7 @@ namespace Duplicati.Library.Backend.TencentCOS
private const string COS_SECRET_ID = "cos-secret-id";
private const string COS_SECRET_KEY = "cos-secret-key";
private const string COS_BUCKET = "cos-bucket";
+ private const string COS_STORAGE_CLASS = "cos-storage-class";
/// <summary>
/// Set default HTTPS request
@@ -81,6 +82,11 @@ namespace Duplicati.Library.Backend.TencentCOS
/// A path or subfolder in a bucket
/// </summary>
public string Path { get; set; }
+ /// <summary>
+ /// Storage class of the object
+ /// https://cloud.tencent.com/document/product/436/33417
+ /// </summary>
+ public string StorageClass { get; set; }
}
public COS() { }
@@ -121,6 +127,11 @@ namespace Duplicati.Library.Backend.TencentCOS
{
_cosOptions.Bucket = options[COS_BUCKET];
}
+
+ if (options.ContainsKey(COS_STORAGE_CLASS))
+ {
+ _cosOptions.StorageClass = options[COS_STORAGE_CLASS];
+ }
}
CosXml GetCosXml()
@@ -290,6 +301,10 @@ namespace Duplicati.Library.Backend.TencentCOS
request.SetSign(TimeUtils.GetCurrentTime(TimeUnit.SECONDS), KEY_DURATION_SECOND);
request.SetRequestHeader("Content-Type", "application/octet-stream");
+ if (!string.IsNullOrEmpty(_cosOptions.StorageClass))
+ {
+ request.SetRequestHeader("x-" + COS_STORAGE_CLASS, _cosOptions.StorageClass);
+ }
PutObjectResult result = cosXml.PutObject(request);
}
@@ -348,8 +363,7 @@ namespace Duplicati.Library.Backend.TencentCOS
string sourceRegion = _cosOptions.Region;
string sourceKey = GetFullKey(oldname);
- CopySourceStruct copySource = new CopySourceStruct(sourceAppid, sourceBucket,
- sourceRegion, sourceKey);
+ CopySourceStruct copySource = new CopySourceStruct(sourceAppid, sourceBucket, sourceRegion, sourceKey);
string bucket = _cosOptions.Bucket;
string key = GetFullKey(newname);
@@ -388,11 +402,12 @@ namespace Duplicati.Library.Backend.TencentCOS
get
{
return new List<ICommandLineArgument>(new ICommandLineArgument[] {
- new CommandLineArgument(COS_APP_ID, CommandLineArgument.ArgumentType.String, Strings.COSBackend.COSAccountDescriptionShort,Strings.COSBackend.COSAccountDescriptionLong),
- new CommandLineArgument(COS_REGION, CommandLineArgument.ArgumentType.String, Strings.COSBackend.COSLocationDescriptionShort,Strings.COSBackend.COSLocationDescriptionLong),
- new CommandLineArgument(COS_SECRET_ID, CommandLineArgument.ArgumentType.String, Strings.COSBackend.COSAPISecretIdDescriptionShort,Strings.COSBackend.COSAPISecretIdDescriptionLong),
- new CommandLineArgument(COS_SECRET_KEY, CommandLineArgument.ArgumentType.Password, Strings.COSBackend.COSAPISecretKeyDescriptionShort,Strings.COSBackend.COSAPISecretKeyDescriptionLong),
- new CommandLineArgument(COS_BUCKET, CommandLineArgument.ArgumentType.String,Strings.COSBackend.COSBucketDescriptionShort,Strings.COSBackend.COSBucketDescriptionLong),
+ new CommandLineArgument(COS_APP_ID, CommandLineArgument.ArgumentType.String, Strings.COSBackend.COSAccountDescriptionShort, Strings.COSBackend.COSAccountDescriptionLong),
+ new CommandLineArgument(COS_REGION, CommandLineArgument.ArgumentType.String, Strings.COSBackend.COSLocationDescriptionShort, Strings.COSBackend.COSLocationDescriptionLong),
+ new CommandLineArgument(COS_SECRET_ID, CommandLineArgument.ArgumentType.String, Strings.COSBackend.COSAPISecretIdDescriptionShort, Strings.COSBackend.COSAPISecretIdDescriptionLong),
+ new CommandLineArgument(COS_SECRET_KEY, CommandLineArgument.ArgumentType.Password, Strings.COSBackend.COSAPISecretKeyDescriptionShort, Strings.COSBackend.COSAPISecretKeyDescriptionLong),
+ new CommandLineArgument(COS_BUCKET, CommandLineArgument.ArgumentType.String, Strings.COSBackend.COSBucketDescriptionShort, Strings.COSBackend.COSBucketDescriptionLong),
+ new CommandLineArgument(COS_STORAGE_CLASS, CommandLineArgument.ArgumentType.String, Strings.COSBackend.COSStorageClassDescriptionShort, Strings.COSBackend.COSStorageClassDescriptionLong)
});
}
}
diff --git a/Duplicati/Library/Backend/TencentCOS/Strings.cs b/Duplicati/Library/Backend/TencentCOS/Strings.cs
index 65fe0ff37..9d02eb7e9 100644
--- a/Duplicati/Library/Backend/TencentCOS/Strings.cs
+++ b/Duplicati/Library/Backend/TencentCOS/Strings.cs
@@ -21,6 +21,9 @@ namespace Duplicati.Library.Backend.Strings
public static string COSLocationDescriptionShort { get { return LC.L(@"Specifies COS location constraints"); } }
public static string COSLocationDescriptionLong { get { return LC.L(@"Region (Region) is the distribution area of ​​the Tencent cloud hosting machine room, the object storage COS data is stored in the storage buckets of these regions. https://cloud.tencent.com/document/product/436/6224"); } }
+
+ public static string COSStorageClassDescriptionShort { get { return LC.L(@"Storage class of the object"); } }
+ public static string COSStorageClassDescriptionLong { get { return LC.L(@"Storage class of the object; check enumerated values at https://cloud.tencent.com/document/product/436/33417."); } }
}
}