Created
April 14, 2015 21:46
-
-
Save wilsaj/85ad9a16ff8c5191bde1 to your computer and use it in GitHub Desktop.
boto multipart copy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _s3_multipart_copy(old_bucket, old_key, new_bucket, new_key): | |
old_key_obj = old_bucket.lookup(old_key) | |
key_size = old_key_obj.size | |
part_size = 1000000000 | |
parts = [ | |
(i+1, i * part_size, min(key_size - 1, ((i + 1) * part_size) - 1)) | |
for i in range((old_key_obj.size / part_size) + 1) | |
] | |
multipart = new_bucket.initiate_multipart_upload(new_key) | |
for (i, start, end) in parts: | |
print("copying %s part %s of %s " % (old_key, i, len(parts))) | |
multipart.copy_part_from_key(etl_config.old_bucket, old_key, i, start, end) | |
multipart.complete_upload() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment