multipart_upload_5.py 871 B

12345678910111213141516171819202122
  1. def clean_unfinished_upload(self, upload_id_list):
  2. """
  3. 清理(abort)未完成的分片上传
  4. :param upload_id_list: 未完成分片上传的 upload id
  5. :return:
  6. """
  7. if upload_id_list:
  8. keyboard_input = raw_input("是否清理未完成分片,输入 yes 完成清理,其他代表不清理\n")
  9. if keyboard_input == "yes":
  10. for upload_info in upload_id_list:
  11. self.s3_client.abort_multipart_upload(
  12. Bucket=DESTINATION_BUCKET,
  13. Key=upload_info["Key"],
  14. UploadId=upload_info["UploadId"]
  15. )
  16. print ("清理分片对象 :{}, UploadId : {}".format(upload_info["Key"], upload_info["UploadId"]))
  17. return True
  18. else:
  19. print ("不清理未完成分片上传信息")
  20. return False