Created
September 27, 2013 16:24
-
-
Save comzeradd/6731197 to your computer and use it in GitHub Desktop.
[boto] force multipart ETag to match MD5 hash by copying it to a new file
This file contains 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
from boto.s3.connection import S3Connection | |
# initiate the connection | |
conn = S3Connection(ACCESSKEY, SECRETKEY) | |
b = conn.get_bucket(BUCKET) | |
# Create a new multipart object out of 2 parts | |
mp = b.initiate_multipart_upload('joinedfile') | |
mp.copy_part_from_key(b.name, 'part1', 1) | |
mp.copy_part_from_key(b.name, 'part2', 2) | |
mp.complete_upload() | |
# Rename (copy & delete) the file to recalculate ETag correctly | |
k = b.get_key('joinedfile') | |
k.copy(b, 'newfile') | |
k.delete() | |
# Get the newfile ETag | |
k = b.get_key('newfile') | |
print k.etag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment