Skip to content

Instantly share code, notes, and snippets.

@comzeradd
Created September 27, 2013 16:24
Show Gist options
  • Save comzeradd/6731197 to your computer and use it in GitHub Desktop.
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
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