12345678910111213141516171819202122232425 |
- def get_upload_id_list(self):
- """
- 获取桶内是否存在未完成的multipart
- :return: 未完成 upload id list
- """
-
- upload_id_list = []
- res = self.s3_client.list_multipart_uploads(Bucket=DESTINATION_BUCKET)
- try:
- # 如果桶内不存在未完成的分片上传,response里就不存在 Uploads 字段
- for upload_info in res["Uploads"]:
- upload_id_list.append(
- {
- "Key": upload_info["Key"],
- "Initiated": upload_info["Initiated"],
- "UploadId": upload_info["UploadId"]
- }
- )
- print ("存在未完成分片 对象名 : {}, 初始化上传时间 : {}".format(upload_info["Key"], upload_info["Initiated"]))
- except Exception as e:
- # TODO 后面需要确定是哪种异常类型
- print ("桶 {} 没有未完成的分片上传".format(DESTINATION_BUCKET))
- return upload_id_list
|