123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- def complete_upload(self, upload_id, len_index_list):
- """
- 合并分片
- :param upload_id:
- :param len_index_list:
- :return:
- """
- uploaded_list_parts_clean = []
- part_number_marker = 0
- is_truncated = True
- while is_truncated:
- res = self.s3_client.list_parts(
- Bucket=DESTINATION_BUCKET,
- Key=MULTIPART_UPLOAD_FILE_NAME,
- UploadId=upload_id,
- MaxParts=1000,
- PartNumberMarker=part_number_marker
- )
- next_part_number_marker = res["NextPartNumberMarker"]
- is_truncated = res["IsTruncated"]
- if next_part_number_marker > 0:
- for part_object in res["Parts"]:
- e_tag = part_object["ETag"]
- part_number = part_object["PartNumber"]
- add_up = {
- "ETag": e_tag,
- "PartNumber": part_number
- }
- uploaded_list_parts_clean.append(add_up)
- part_number_marker = next_part_number_marker
- if len(uploaded_list_parts_clean) != len_index_list:
- print ("以上传分片数量与源文件分片数量不匹配!!!")
- sys.exit(-1)
- complete_struck_json = {
- "Parts": uploaded_list_parts_clean
- }
- res = self.s3_client.complete_multipart_upload(
- Bucket=DESTINATION_BUCKET,
- Key=MULTIPART_UPLOAD_FILE_NAME,
- UploadId=upload_id,
- MultipartUpload=complete_struck_json
- )
-
|