multipart_upload_12.py 814 B

1234567891011121314151617181920
  1. def upload_virtual_file_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. part_data_body = CHUNK_SIZE * "a"
  12. with futures.ThreadPoolExecutor(max_workers=MAX_THREADS) as pool:
  13. for part_start_index in index_list:
  14. if part_number not in part_number_list:
  15. pool.submit(self.upload_virtual_file_thread, upload_id, part_number, part_data_body, total)
  16. part_number += 1
  17. print ("所有分片文件已上传, 文件名: {}, 文件大小:{}".format(MULTIPART_UPLOAD_FILE_NAME, MULTIPART_UPLOAD_FILE_SIZE))
  18. return part_number - 1