Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. else:
  2. print('Transferring File from FTP to 53 in chunks...')
  3. #upload file in chunks
  4. chunk_count = int(math.ceil(ftp_file_size / float(chunk_size)))
  5. multipart_upload = s3_connection.create_multipart_upload(Bucket = bucket_name, Key = s3_file_path)
  6. parts = []
  7. for i in range(chunk count):
  8. print('Transferring chunk {}...'.format(i + 1))
  9. part = transfer_chunk_from_ftp_to_s3(
  10. ftp_file,
  11. s3_connection,
  12. multipart_upload,
  13. bucket_name,
  14. ftp_file_path,
  15. s3_file_path,
  16. i + 1,
  17. chunksize
  18. )
  19. parts.append(part)
  20. print('Chunk .0. Transferred Successfully!'.format(i + 1))
  21.  
  22. part_info = {
  23. 'Parts': parts
  24. }
  25. s3_connection.complete_multipart_upload(
  26. Bucket = bucket_name,
  27. Key = s3_file_path,
  28. UpLoadld = multipart_uploadUllploadIdl,
  29. MuLtipartUpLoad = part_info
  30. )
  31. print('All chunks Transferred to 53 bucket! File Transfer successful!')
  32. ftp_file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement