12345678910111213141516171819202122232425262728293031 |
- def check_part_number_list(self, upload_id):
- """
- 检查是否存在以上传的分片
- :param upload_id: 未完成分片上传文件的upload_id
- :return:
- """
- try:
- is_truncated = True
- part_number_marker = 0
- part_number_list = []
- 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_number_object in res["Parts"]:
- part_number_list.append(part_number_object["PartNumber"])
- part_number_marker = next_part_number_marker
- if part_number_list:
- print ("已存在上传分片 : {}".format(part_number_list))
- except Exception as e:
- print ("Exception error {}, quit \n".format(e.message))
- sys.exit(-1)
- return part_number_list
|