Skip to content

Commit

Permalink
object lifecycle add archiveIR
Browse files Browse the repository at this point in the history
  • Loading branch information
lihsai0 committed Nov 28, 2023
1 parent 5c849f7 commit 77af949
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
20 changes: 13 additions & 7 deletions src/Qiniu/Storage/BucketManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,8 @@ public HttpResult SetObjectLifecycle(
int toIaAfterDays = 0,
int toArchiveAfterDays = 0,
int toDeepArchiveAfterDays = 0,
int deleteAfterDays = 0
int deleteAfterDays = 0,
int toArchiveIrAfterDays = 0
)
{
return SetObjectLifecycle(
Expand All @@ -717,7 +718,8 @@ public HttpResult SetObjectLifecycle(
toIaAfterDays,
toArchiveAfterDays,
toDeepArchiveAfterDays,
deleteAfterDays
deleteAfterDays,
toArchiveIrAfterDays
);
}

Expand All @@ -728,6 +730,7 @@ public HttpResult SetObjectLifecycle(
/// <param name="key">文件key</param>
/// <param name="cond">匹配条件,只有条件匹配才会设置成功,目前支持:hash、mime、fsize、putTime</param>
/// <param name="toIaAfterDays">多少天后将文件转为低频存储,设置为 -1 表示取消已设置的转低频存储的生命周期规则,0 表示不修改转低频生命周期规则。</param>
/// <param name="toArchiveIrAfterDays">多少天后将文件转为归档直读存储,设置为 -1 表示取消已设置的转归档直读存储的生命周期规则,0 表示不修改转归档直读生命周期规则。</param>
/// <param name="toArchiveAfterDays">多少天后将文件转为归档存储,设置为 -1 表示取消已设置的转归档存储的生命周期规则,0 表示不修改转归档生命周期规则。</param>
/// <param name="toDeepArchiveAfterDays">多少天后将文件转为深度归档存储,设置为 -1 表示取消已设置的转深度归档存储的生命周期规则,0 表示不修改转深度归档生命周期规则。</param>
/// <param name="deleteAfterDays">多少天后将文件删除,设置为 -1 表示取消已设置的删除存储的生命周期规则,0 表示不修改删除存储的生命周期规则。</param>
Expand All @@ -739,15 +742,16 @@ public HttpResult SetObjectLifecycle(
int toIaAfterDays = 0,
int toArchiveAfterDays = 0,
int toDeepArchiveAfterDays = 0,
int deleteAfterDays = 0
int deleteAfterDays = 0,
int toArchiveIrAfterDays = 0
)
{
HttpResult result = new HttpResult();

try
{
string updateUrl = string.Format("{0}{1}", this.config.RsHost(this.mac.AccessKey, bucket),
SetObjectLifecycleOp(bucket, key, cond, toIaAfterDays, toArchiveAfterDays, toDeepArchiveAfterDays, deleteAfterDays));
SetObjectLifecycleOp(bucket, key, cond, toIaAfterDays, toArchiveAfterDays, toDeepArchiveAfterDays, deleteAfterDays, toArchiveIrAfterDays));
StringDictionary headers = new StringDictionary
{
{"Content-Type", ContentType.WWW_FORM_URLENC}
Expand Down Expand Up @@ -954,6 +958,7 @@ public string DeleteAfterDaysOp(string bucket, string key, int deleteAfterDays)
/// <param name="key">文件key</param>
/// <param name="cond">匹配条件,只有条件匹配才会设置成功,目前支持:hash、mime、fsize、putTime</param>
/// <param name="toIaAfterDays">多少天后将文件转为低频存储,设置为 -1 表示取消已设置的转低频存储的生命周期规则,0 表示不修改转低频生命周期规则。</param>
/// <param name="toArchiveIrAfterDays">多少天后将文件转为归档直读存储,设置为 -1 表示取消已设置的转归档直读存储的生命周期规则,0 表示不修改转归档直读生命周期规则。</param>
/// <param name="toArchiveAfterDays">多少天后将文件转为归档存储,设置为 -1 表示取消已设置的转归档存储的生命周期规则,0 表示不修改转归档生命周期规则。</param>
/// <param name="toDeepArchiveAfterDays">多少天后将文件转为深度归档存储,设置为 -1 表示取消已设置的转深度归档存储的生命周期规则,0 表示不修改转深度归档生命周期规则。</param>
/// <param name="deleteAfterDays">多少天后将文件删除,设置为 -1 表示取消已设置的删除存储的生命周期规则,0 表示不修改删除存储的生命周期规则。</param>
Expand All @@ -965,13 +970,14 @@ public string SetObjectLifecycleOp(
int toIaAfterDays = 0,
int toArchiveAfterDays = 0,
int toDeepArchiveAfterDays = 0,
int deleteAfterDays = 0
int deleteAfterDays = 0,
int toArchiveIrAfterDays = 0
)
{
string entry = Base64.UrlSafeBase64Encode(bucket, key);
string result = string.Format(
"/lifecycle/{0}/toIAAfterDays/{1}/toArchiveAfterDays/{2}/toDeepArchiveAfterDays/{3}/deleteAfterDays/{4}",
entry, toIaAfterDays, toArchiveAfterDays, toDeepArchiveAfterDays, deleteAfterDays);
"/lifecycle/{0}/toIAAfterDays/{1}/toArchiveIRAfterDays/{2}/toArchiveAfterDays/{3}/toDeepArchiveAfterDays/{4}/deleteAfterDays/{5}",
entry, toIaAfterDays, toArchiveIrAfterDays, toArchiveAfterDays, toDeepArchiveAfterDays, deleteAfterDays);

if (cond != null)
{
Expand Down
10 changes: 9 additions & 1 deletion src/Qiniu/Storage/FileInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,17 @@ public class FileInfo
/// 文件在设置过期时间后才会返回该字段。
/// 历史文件过期仍会自动删除,但不会返回该字段,重新设置文件过期时间可使历史文件返回该字段。
/// </summary>
[JsonProperty("TransitionToIA", NullValueHandling = NullValueHandling.Ignore)]
[JsonProperty("transitionToIA", NullValueHandling = NullValueHandling.Ignore)]
public int TransitionToIa { get; set; }

/// <summary>
/// 文件生命周期中转为归档直读存储的日期,Unix 时间戳格式。
/// 文件在设置过期时间后才会返回该字段。
/// 历史文件过期仍会自动删除,但不会返回该字段,重新设置文件过期时间可使历史文件返回该字段。
/// </summary>
[JsonProperty("transitionToArchiveIR", NullValueHandling = NullValueHandling.Ignore)]
public int TransitionToArchiveIr { get; set; }

/// <summary>
/// 文件生命周期中转为归档存储的日期,Unix 时间戳格式。
/// 文件在设置过期时间后才会返回该字段。
Expand Down
7 changes: 5 additions & 2 deletions src/QiniuTests/Storage/BucketManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ public void SetObjectLifecycleTest()
10,
20,
30,
40);
40,
15);
if (ret.Code != (int)HttpCode.OK)
{
Assert.Fail("deleteAfterDays error: " + ret.ToString());
Expand All @@ -279,6 +280,7 @@ public void SetObjectLifecycleTest()
Assert.Fail("stat error: " + statRet.ToString());
}
Assert.True(statRet.Result.TransitionToIa > 0);
Assert.True(statRet.Result.TransitionToArchiveIr > 0);
Assert.True(statRet.Result.TransitionToArchive > 0);
Assert.True(statRet.Result.TransitionToDeepArchive > 0);
Assert.True(statRet.Result.Expiration > 0);
Expand Down Expand Up @@ -318,7 +320,8 @@ public void SetObjectLifecycleCondTest()
10,
20,
30,
40);
40,
15);
if (ret.Code != (int)HttpCode.OK)
{
Assert.Fail("deleteAfterDays error: " + ret.ToString());
Expand Down

0 comments on commit 77af949

Please sign in to comment.