multipart_upload_11.py 740 B

12345678910111213141516171819
  1. def upload_part(self, upload_id, index_list, part_number_list):
  2. """
  3. 多线程上传分片
  4. :param upload_id: 分片上传的upload id
  5. :param index_list: 所有分片的
  6. :param part_number_list:
  7. :return:
  8. """
  9. part_number = 1
  10. total = len(index_list)
  11. with futures.ThreadPoolExecutor(max_workers=MAX_THREADS) as pool:
  12. for part_start_index in index_list:
  13. if part_number not in part_number_list:
  14. pool.submit(self.upload_thread, upload_id, part_number, part_start_index, total)
  15. part_number += 1
  16. print ("所有分片文件已上传, 文件名: {}, 文件大小:{}".format(MULTIPART_UPLOAD_FILE_NAME, MULTIPART_UPLOAD_FILE_SIZE))
  17. return part_number - 1