@@ -2340,7 +2340,10 @@ def _inner_head_object(self, CopySource):
2340
2340
auth = CosS3Auth (self ._conf , path , params = params ),
2341
2341
headers = {},
2342
2342
params = params )
2343
- return int (rt .headers ['Content-Length' ])
2343
+ storage_class = 'standard'
2344
+ if 'x-cos-storage-class' in rt .headers :
2345
+ storage_class = rt .headers ['x-cos-storage-class' ].lower ()
2346
+ return int (rt .headers ['Content-Length' ]), storage_class
2344
2347
2345
2348
def _upload_part_copy (self , bucket , key , part_number , upload_id , copy_source , copy_source_range , md5_lst ):
2346
2349
"""拷贝指定文件至分块上传,记录结果到lst中去
@@ -2389,13 +2392,18 @@ def copy(self, Bucket, Key, CopySource, CopyStatus='Copy', PartSize=10, MAXThrea
2389
2392
MAXThread=10
2390
2393
)
2391
2394
"""
2392
- # 同园区直接走copy_object
2393
- if self ._check_same_region (self ._conf ._endpoint , CopySource ) and 'StorageClass' not in kwargs :
2395
+ # 先查询下拷贝源object的content-length
2396
+ file_size , src_storage_class = self ._inner_head_object (CopySource )
2397
+
2398
+ dst_storage_class = 'standard'
2399
+ if 'StorageClass' in kwargs :
2400
+ dst_storage_class = kwargs ['StorageClass' ].lower ()
2401
+
2402
+ # 同园区且不改存储类型的情况下直接走copy_object
2403
+ if self ._check_same_region (self ._conf ._endpoint , CopySource ) and src_storage_class == dst_storage_class :
2394
2404
response = self .copy_object (Bucket = Bucket , Key = Key , CopySource = CopySource , CopyStatus = CopyStatus , ** kwargs )
2395
2405
return response
2396
2406
2397
- # 不同园区查询拷贝源object的content-length
2398
- file_size = self ._inner_head_object (CopySource )
2399
2407
# 如果源文件大小小于5G,则直接调用copy_object接口
2400
2408
if file_size < SINGLE_UPLOAD_LENGTH :
2401
2409
response = self .copy_object (Bucket = Bucket , Key = Key , CopySource = CopySource , CopyStatus = CopyStatus , ** kwargs )
0 commit comments