1234567891011121314151617181920212223242526272829303132 |
- def upload_thread(self, upload_id, part_number, part_start_index, total):
- """
- :param upload_id: multipart upload id
- :param part_number: 分片数
- :param part_start_index: 分片在文件的偏移位置
- :param total:总分片量
- :return:
- """
- print ("Uploading {} / {}".format(part_number, total))
- with open(MULTIPART_UPLOAD_FILE, "rb") as data:
- retry_time = 0
- while retry_time <= MAX_RETRY_TIME:
- try:
- data.seek(part_start_index)
- self.s3_client.upload_part(
- Body=data.read(CHUNK_SIZE),
- Bucket=DESTINATION_BUCKET,
- Key=MULTIPART_UPLOAD_FILE_NAME,
- PartNumber=part_number,
- UploadId=upload_id
- )
- break
- except Exception as e:
- retry_time += 1
-
- if retry_time > MAX_RETRY_TIME:
-
- sys.exit(-1)
- time.sleep(5)
- print (" Complete {} / {} ".format(part_number, total))
|