@@ -153,7 +153,7 @@ def send_request(self, method, url, timeout=30, **kwargs):
153153 timeout = self ._conf ._timeout
154154 if self ._conf ._token is not None :
155155 kwargs ['headers' ]['x-cos-security-token' ] = self ._conf ._token
156- kwargs ['headers' ]['User-Agent' ] = 'cos-python-sdk-v5.1.4.1 '
156+ kwargs ['headers' ]['User-Agent' ] = 'cos-python-sdk-v5.1.4.2 '
157157 try :
158158 for j in range (self ._retry ):
159159 if method == 'POST' :
@@ -391,7 +391,7 @@ def delete_objects(self, Bucket, Delete={}, **kwargs):
391391 auth = CosS3Auth (self ._conf ._secret_id , self ._conf ._secret_key ),
392392 headers = headers )
393393 data = xml_to_dict (rt .text )
394- data = format_dict (data , ['Deleted' , 'Error' ])
394+ format_dict (data , ['Deleted' , 'Error' ])
395395 return data
396396
397397 def head_object (self , Bucket , Key , ** kwargs ):
@@ -723,9 +723,9 @@ def list_parts(self, Bucket, Key, UploadId, EncodingType='', MaxParts=1000, Part
723723 headers = headers ,
724724 params = params )
725725 data = xml_to_dict (rt .text )
726- data = format_dict (data , ['Part' ])
726+ format_dict (data , ['Part' ])
727727 if decodeflag :
728- data = decode_result (data , ['Key' ], [])
728+ decode_result (data , ['Key' ], [])
729729 return data
730730
731731 def put_object_acl (self , Bucket , Key , AccessControlPolicy = {}, ** kwargs ):
@@ -938,9 +938,9 @@ def list_objects(self, Bucket, Prefix="", Delimiter="", Marker="", MaxKeys=1000,
938938 headers = headers ,
939939 auth = CosS3Auth (self ._conf ._secret_id , self ._conf ._secret_key ))
940940 data = xml_to_dict (rt .text )
941- data = format_dict (data , ['Contents' , 'CommonPrefixes' ])
941+ format_dict (data , ['Contents' , 'CommonPrefixes' ])
942942 if decodeflag :
943- data = decode_result (
943+ decode_result (
944944 data ,
945945 [
946946 'Prefix' ,
@@ -1006,9 +1006,9 @@ def list_objects_versions(self, Bucket, Prefix="", Delimiter="", KeyMarker="", V
10061006 headers = headers ,
10071007 auth = CosS3Auth (self ._conf ._secret_id , self ._conf ._secret_key ))
10081008 data = xml_to_dict (rt .text )
1009- data = format_dict (data , ['Version' , 'DeleteMarker' , 'CommonPrefixes' ])
1009+ format_dict (data , ['Version' , 'DeleteMarker' , 'CommonPrefixes' ])
10101010 if decodeflag :
1011- data = decode_result (
1011+ decode_result (
10121012 data ,
10131013 [
10141014 'Prefix' ,
@@ -1078,9 +1078,9 @@ def list_multipart_uploads(self, Bucket, Prefix="", Delimiter="", KeyMarker="",
10781078 auth = CosS3Auth (self ._conf ._secret_id , self ._conf ._secret_key ))
10791079
10801080 data = xml_to_dict (rt .text )
1081- data = format_dict (data , ['Upload' , 'CommonPrefixes' ])
1081+ format_dict (data , ['Upload' , 'CommonPrefixes' ])
10821082 if decodeflag :
1083- data = decode_result (
1083+ decode_result (
10841084 data ,
10851085 [
10861086 'Prefix' ,
@@ -1349,7 +1349,17 @@ def put_bucket_lifecycle(self, Bucket, LifecycleConfiguration={}, **kwargs):
13491349 LifecycleConfiguration=lifecycle_config
13501350 )
13511351 """
1352- lst = ['<Rule>' , '<Tag>' , '</Tag>' , '</Rule>' ] # 类型为list的标签
1352+ # 类型为list的标签
1353+ lst = [
1354+ '<Rule>' ,
1355+ '<Tag>' ,
1356+ '<Transition>' ,
1357+ '<NoncurrentVersionTransition>' ,
1358+ '</NoncurrentVersionTransition>' ,
1359+ '</Transition>' ,
1360+ '</Tag>' ,
1361+ '</Rule>'
1362+ ]
13531363 xml_config = format_xml (data = LifecycleConfiguration , root = 'LifecycleConfiguration' , lst = lst )
13541364 headers = mapped (kwargs )
13551365 headers ['Content-MD5' ] = get_md5 (xml_config )
@@ -1393,7 +1403,12 @@ def get_bucket_lifecycle(self, Bucket, **kwargs):
13931403 auth = CosS3Auth (self ._conf ._secret_id , self ._conf ._secret_key ),
13941404 headers = headers )
13951405 data = xml_to_dict (rt .text )
1396- data = format_dict (data , ['Rule' ])
1406+ format_dict (data , ['Rule' ])
1407+ if 'Rule' in data .keys ():
1408+ for rule in data ['Rule' ]:
1409+ format_dict (rule , ['Transition' , 'NoncurrentVersionTransition' ])
1410+ if 'Filter' in rule .keys ():
1411+ format_dict (rule ['Filter' ], ['Tag' ])
13971412 return data
13981413
13991414 def delete_bucket_lifecycle (self , Bucket , ** kwargs ):
@@ -1596,7 +1611,7 @@ def get_bucket_replication(self, Bucket, **kwargs):
15961611 auth = CosS3Auth (self ._conf ._secret_id , self ._conf ._secret_key ),
15971612 headers = headers )
15981613 data = xml_to_dict (rt .text )
1599- data = format_dict (data , ['Rule' ])
1614+ format_dict (data , ['Rule' ])
16001615 return data
16011616
16021617 def delete_bucket_replication (self , Bucket , ** kwargs ):
@@ -1814,11 +1829,12 @@ def _check_all_upload_parts(self, bucket, key, uploadid, local_path, parts_num,
18141829 UploadId = uploadid ,
18151830 PartNumberMarker = part_number_marker
18161831 )
1817- parts_info .extend (response ['Part' ])
1832+ if 'Part' in response :
1833+ parts_info .extend (response ['Part' ])
18181834 if response ['IsTruncated' ] == 'false' :
18191835 list_over_status = True
18201836 else :
1821- part_number_marker = int (response ['NextMarker ' ])
1837+ part_number_marker = int (response ['NextPartNumberMarker ' ])
18221838 for part in parts_info :
18231839 part_num = int (part ['PartNumber' ])
18241840 # 如果分块数量大于本地计算出的最大数量,校验失败
0 commit comments