@@ -338,7 +338,14 @@ public HttpResult ChangeStatus(string bucket, string key, int status)
338338 /// </summary>
339339 /// <param name="bucket">空间名称</param>
340340 /// <param name="key">文件key</param>
341- /// <param name="fileType">修改后的文件存储类型,0表示普通存储,1表示低频存储,2表示归档存储,3表示深度归档存储</param>
341+ /// <param name="fileType">
342+ /// 修改后的文件存储类型:
343+ /// 0 表示普通存储;
344+ /// 1 表示低频存储;
345+ /// 2 表示归档存储;
346+ /// 3 表示深度归档存储;
347+ /// 4 表示归档直读存储;
348+ /// </param>
342349 /// <returns>状态码为200时表示OK</returns>
343350 public HttpResult ChangeType ( string bucket , string key , int fileType )
344351 {
@@ -414,11 +421,36 @@ private BatchResult Batch(string batchOps)
414421 {
415422 BatchResult result = new BatchResult ( ) ;
416423
424+ string bucket = "" ;
425+ foreach ( string op in batchOps . Split ( '&' ) )
426+ {
427+ string [ ] segments = op . Split ( '/' ) ;
428+ if ( segments . Length < 3 )
429+ {
430+ continue ;
431+ }
432+
433+ string entry = Encoding . UTF8 . GetString ( Base64 . UrlsafeBase64Decode ( segments [ 2 ] ) ) ;
434+ bucket = entry . Split ( ':' ) [ 0 ] ;
435+
436+ if ( bucket . Length > 0 )
437+ {
438+ break ;
439+ }
440+ }
441+
442+ if ( bucket . Length == 0 )
443+ {
444+ result . Code = ( int ) HttpCode . INVALID_ARGUMENT ;
445+ result . RefCode = ( int ) HttpCode . INVALID_ARGUMENT ;
446+ result . Text = "{\" error\" :\" bucket is Empty\" }" ;
447+ result . RefText = "bucket is Empty" ;
448+ return result ;
449+ }
450+
417451 try
418452 {
419- string scheme = this . config . UseHttps ? "https://" : "http://" ;
420- string rsHost = string . Format ( "{0}{1}" , scheme , Config . DefaultRsHost ) ;
421- string batchUrl = rsHost + "/batch" ;
453+ string batchUrl = string . Format ( "{0}/batch" , this . config . RsHost ( this . mac . AccessKey , bucket ) ) ;
422454
423455 HttpResult hr = httpManager . PostForm ( batchUrl , null , batchOps , auth ) ;
424456 result . Shadow ( hr ) ;
@@ -707,7 +739,8 @@ public HttpResult SetObjectLifecycle(
707739 int toIaAfterDays = 0 ,
708740 int toArchiveAfterDays = 0 ,
709741 int toDeepArchiveAfterDays = 0 ,
710- int deleteAfterDays = 0
742+ int deleteAfterDays = 0 ,
743+ int toArchiveIrAfterDays = 0
711744 )
712745 {
713746 return SetObjectLifecycle (
@@ -717,7 +750,8 @@ public HttpResult SetObjectLifecycle(
717750 toIaAfterDays ,
718751 toArchiveAfterDays ,
719752 toDeepArchiveAfterDays ,
720- deleteAfterDays
753+ deleteAfterDays ,
754+ toArchiveIrAfterDays
721755 ) ;
722756 }
723757
@@ -728,6 +762,7 @@ public HttpResult SetObjectLifecycle(
728762 /// <param name="key">文件key</param>
729763 /// <param name="cond">匹配条件,只有条件匹配才会设置成功,目前支持:hash、mime、fsize、putTime</param>
730764 /// <param name="toIaAfterDays">多少天后将文件转为低频存储,设置为 -1 表示取消已设置的转低频存储的生命周期规则,0 表示不修改转低频生命周期规则。</param>
765+ /// <param name="toArchiveIrAfterDays">多少天后将文件转为归档直读存储,设置为 -1 表示取消已设置的转归档直读存储的生命周期规则,0 表示不修改转归档直读生命周期规则。</param>
731766 /// <param name="toArchiveAfterDays">多少天后将文件转为归档存储,设置为 -1 表示取消已设置的转归档存储的生命周期规则,0 表示不修改转归档生命周期规则。</param>
732767 /// <param name="toDeepArchiveAfterDays">多少天后将文件转为深度归档存储,设置为 -1 表示取消已设置的转深度归档存储的生命周期规则,0 表示不修改转深度归档生命周期规则。</param>
733768 /// <param name="deleteAfterDays">多少天后将文件删除,设置为 -1 表示取消已设置的删除存储的生命周期规则,0 表示不修改删除存储的生命周期规则。</param>
@@ -739,15 +774,16 @@ public HttpResult SetObjectLifecycle(
739774 int toIaAfterDays = 0 ,
740775 int toArchiveAfterDays = 0 ,
741776 int toDeepArchiveAfterDays = 0 ,
742- int deleteAfterDays = 0
777+ int deleteAfterDays = 0 ,
778+ int toArchiveIrAfterDays = 0
743779 )
744780 {
745781 HttpResult result = new HttpResult ( ) ;
746782
747783 try
748784 {
749785 string updateUrl = string . Format ( "{0}{1}" , this . config . RsHost ( this . mac . AccessKey , bucket ) ,
750- SetObjectLifecycleOp ( bucket , key , cond , toIaAfterDays , toArchiveAfterDays , toDeepArchiveAfterDays , deleteAfterDays ) ) ;
786+ SetObjectLifecycleOp ( bucket , key , cond , toIaAfterDays , toArchiveAfterDays , toDeepArchiveAfterDays , deleteAfterDays , toArchiveIrAfterDays ) ) ;
751787 StringDictionary headers = new StringDictionary
752788 {
753789 { "Content-Type" , ContentType . WWW_FORM_URLENC }
@@ -954,6 +990,7 @@ public string DeleteAfterDaysOp(string bucket, string key, int deleteAfterDays)
954990 /// <param name="key">文件key</param>
955991 /// <param name="cond">匹配条件,只有条件匹配才会设置成功,目前支持:hash、mime、fsize、putTime</param>
956992 /// <param name="toIaAfterDays">多少天后将文件转为低频存储,设置为 -1 表示取消已设置的转低频存储的生命周期规则,0 表示不修改转低频生命周期规则。</param>
993+ /// <param name="toArchiveIrAfterDays">多少天后将文件转为归档直读存储,设置为 -1 表示取消已设置的转归档直读存储的生命周期规则,0 表示不修改转归档直读生命周期规则。</param>
957994 /// <param name="toArchiveAfterDays">多少天后将文件转为归档存储,设置为 -1 表示取消已设置的转归档存储的生命周期规则,0 表示不修改转归档生命周期规则。</param>
958995 /// <param name="toDeepArchiveAfterDays">多少天后将文件转为深度归档存储,设置为 -1 表示取消已设置的转深度归档存储的生命周期规则,0 表示不修改转深度归档生命周期规则。</param>
959996 /// <param name="deleteAfterDays">多少天后将文件删除,设置为 -1 表示取消已设置的删除存储的生命周期规则,0 表示不修改删除存储的生命周期规则。</param>
@@ -965,13 +1002,14 @@ public string SetObjectLifecycleOp(
9651002 int toIaAfterDays = 0 ,
9661003 int toArchiveAfterDays = 0 ,
9671004 int toDeepArchiveAfterDays = 0 ,
968- int deleteAfterDays = 0
1005+ int deleteAfterDays = 0 ,
1006+ int toArchiveIrAfterDays = 0
9691007 )
9701008 {
9711009 string entry = Base64 . UrlSafeBase64Encode ( bucket , key ) ;
9721010 string result = string . Format (
973- "/lifecycle/{0}/toIAAfterDays/{1}/toArchiveAfterDays /{2}/toDeepArchiveAfterDays /{3}/deleteAfterDays /{4}" ,
974- entry , toIaAfterDays , toArchiveAfterDays , toDeepArchiveAfterDays , deleteAfterDays ) ;
1011+ "/lifecycle/{0}/toIAAfterDays/{1}/toArchiveIRAfterDays /{2}/toArchiveAfterDays /{3}/toDeepArchiveAfterDays /{4}/deleteAfterDays/{5 }" ,
1012+ entry , toIaAfterDays , toArchiveIrAfterDays , toArchiveAfterDays , toDeepArchiveAfterDays , deleteAfterDays ) ;
9751013
9761014 if ( cond != null )
9771015 {
@@ -980,7 +1018,6 @@ public string SetObjectLifecycleOp(
9801018
9811019 result += "/cond/" + Base64 . UrlSafeBase64Encode ( query ) ;
9821020 }
983- Console . WriteLine ( result ) ;
9841021
9851022 return result ;
9861023 }
0 commit comments