@@ -122,7 +122,7 @@ def _prepare_temp_file(content):
122122encode_md5 = calculate_data_md5 (content )
123123for i in range (3 ):
124124 result = bucket .upload_part (key , upload_id , i + 1 , content , headers = {'Content-MD5' : encode_md5 })
125- parts .append (oss2 .models .PartInfo (i + 1 , result .etag ))
125+ parts .append (oss2 .models .PartInfo (i + 1 , result .etag , size = len ( content ), part_crc = result . crc ))
126126
127127# 完成上传并回调
128128result = bucket .complete_multipart_upload (key , upload_id , parts )
@@ -156,7 +156,7 @@ def _prepare_temp_file(content):
156156# 上传分片,每个分片单独CRC校验
157157for i in range (3 ):
158158 result = bucket .upload_part (key , upload_id , i + 1 , content )
159- parts .append (oss2 .models .PartInfo (i + 1 , result .etag ))
159+ parts .append (oss2 .models .PartInfo (i + 1 , result .etag , size = len ( content ), part_crc = result . crc ))
160160
161161# 完成上传并回调
162162result = bucket .complete_multipart_upload (key , upload_id , parts )
@@ -178,14 +178,14 @@ def _prepare_temp_file(content):
178178assert result .client_crc == result .server_crc
179179
180180
181- # 下载文件到本地
181+ # 下载文件到本地,默认开启CRC校验
182182local_file = 'download.txt'
183183result = bucket .get_object_to_file (key , local_file )
184184os .remove (local_file )
185185assert result .client_crc == result .server_crc
186186
187187
188- # 断点续传下载,不支持CRC校验,可以用如下方法校验
188+ # 断点续传下载, 自动开启CRC校验,也可以用如下方法校验
189189oss2 .resumable_download (bucket , key , local_file ,
190190 multiget_threshold = 200 * 1024 ,
191191 part_size = 100 * 1024 ,
0 commit comments