@@ -338,7 +338,14 @@ public HttpResult ChangeStatus(string bucket, string key, int status)
338
338
/// </summary>
339
339
/// <param name="bucket">空间名称</param>
340
340
/// <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>
342
349
/// <returns>状态码为200时表示OK</returns>
343
350
public HttpResult ChangeType ( string bucket , string key , int fileType )
344
351
{
@@ -414,11 +421,36 @@ private BatchResult Batch(string batchOps)
414
421
{
415
422
BatchResult result = new BatchResult ( ) ;
416
423
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
+
417
451
try
418
452
{
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 ) ) ;
422
454
423
455
HttpResult hr = httpManager . PostForm ( batchUrl , null , batchOps , auth ) ;
424
456
result . Shadow ( hr ) ;
@@ -707,7 +739,8 @@ public HttpResult SetObjectLifecycle(
707
739
int toIaAfterDays = 0 ,
708
740
int toArchiveAfterDays = 0 ,
709
741
int toDeepArchiveAfterDays = 0 ,
710
- int deleteAfterDays = 0
742
+ int deleteAfterDays = 0 ,
743
+ int toArchiveIrAfterDays = 0
711
744
)
712
745
{
713
746
return SetObjectLifecycle (
@@ -717,7 +750,8 @@ public HttpResult SetObjectLifecycle(
717
750
toIaAfterDays ,
718
751
toArchiveAfterDays ,
719
752
toDeepArchiveAfterDays ,
720
- deleteAfterDays
753
+ deleteAfterDays ,
754
+ toArchiveIrAfterDays
721
755
) ;
722
756
}
723
757
@@ -728,6 +762,7 @@ public HttpResult SetObjectLifecycle(
728
762
/// <param name="key">文件key</param>
729
763
/// <param name="cond">匹配条件,只有条件匹配才会设置成功,目前支持:hash、mime、fsize、putTime</param>
730
764
/// <param name="toIaAfterDays">多少天后将文件转为低频存储,设置为 -1 表示取消已设置的转低频存储的生命周期规则,0 表示不修改转低频生命周期规则。</param>
765
+ /// <param name="toArchiveIrAfterDays">多少天后将文件转为归档直读存储,设置为 -1 表示取消已设置的转归档直读存储的生命周期规则,0 表示不修改转归档直读生命周期规则。</param>
731
766
/// <param name="toArchiveAfterDays">多少天后将文件转为归档存储,设置为 -1 表示取消已设置的转归档存储的生命周期规则,0 表示不修改转归档生命周期规则。</param>
732
767
/// <param name="toDeepArchiveAfterDays">多少天后将文件转为深度归档存储,设置为 -1 表示取消已设置的转深度归档存储的生命周期规则,0 表示不修改转深度归档生命周期规则。</param>
733
768
/// <param name="deleteAfterDays">多少天后将文件删除,设置为 -1 表示取消已设置的删除存储的生命周期规则,0 表示不修改删除存储的生命周期规则。</param>
@@ -739,15 +774,16 @@ public HttpResult SetObjectLifecycle(
739
774
int toIaAfterDays = 0 ,
740
775
int toArchiveAfterDays = 0 ,
741
776
int toDeepArchiveAfterDays = 0 ,
742
- int deleteAfterDays = 0
777
+ int deleteAfterDays = 0 ,
778
+ int toArchiveIrAfterDays = 0
743
779
)
744
780
{
745
781
HttpResult result = new HttpResult ( ) ;
746
782
747
783
try
748
784
{
749
785
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 ) ) ;
751
787
StringDictionary headers = new StringDictionary
752
788
{
753
789
{ "Content-Type" , ContentType . WWW_FORM_URLENC }
@@ -954,6 +990,7 @@ public string DeleteAfterDaysOp(string bucket, string key, int deleteAfterDays)
954
990
/// <param name="key">文件key</param>
955
991
/// <param name="cond">匹配条件,只有条件匹配才会设置成功,目前支持:hash、mime、fsize、putTime</param>
956
992
/// <param name="toIaAfterDays">多少天后将文件转为低频存储,设置为 -1 表示取消已设置的转低频存储的生命周期规则,0 表示不修改转低频生命周期规则。</param>
993
+ /// <param name="toArchiveIrAfterDays">多少天后将文件转为归档直读存储,设置为 -1 表示取消已设置的转归档直读存储的生命周期规则,0 表示不修改转归档直读生命周期规则。</param>
957
994
/// <param name="toArchiveAfterDays">多少天后将文件转为归档存储,设置为 -1 表示取消已设置的转归档存储的生命周期规则,0 表示不修改转归档生命周期规则。</param>
958
995
/// <param name="toDeepArchiveAfterDays">多少天后将文件转为深度归档存储,设置为 -1 表示取消已设置的转深度归档存储的生命周期规则,0 表示不修改转深度归档生命周期规则。</param>
959
996
/// <param name="deleteAfterDays">多少天后将文件删除,设置为 -1 表示取消已设置的删除存储的生命周期规则,0 表示不修改删除存储的生命周期规则。</param>
@@ -965,13 +1002,14 @@ public string SetObjectLifecycleOp(
965
1002
int toIaAfterDays = 0 ,
966
1003
int toArchiveAfterDays = 0 ,
967
1004
int toDeepArchiveAfterDays = 0 ,
968
- int deleteAfterDays = 0
1005
+ int deleteAfterDays = 0 ,
1006
+ int toArchiveIrAfterDays = 0
969
1007
)
970
1008
{
971
1009
string entry = Base64 . UrlSafeBase64Encode ( bucket , key ) ;
972
1010
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 ) ;
975
1013
976
1014
if ( cond != null )
977
1015
{
@@ -980,7 +1018,6 @@ public string SetObjectLifecycleOp(
980
1018
981
1019
result += "/cond/" + Base64 . UrlSafeBase64Encode ( query ) ;
982
1020
}
983
- Console . WriteLine ( result ) ;
984
1021
985
1022
return result ;
986
1023
}
0 commit comments