Last active
January 13, 2019 02:54
-
-
Save tgardiner/be18d1cc965d0f8ebb1e99b87595aee5 to your computer and use it in GitHub Desktop.
Calculate AWS S3 Etag for local file
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 calc_etag(inputfile, partsize): | |
md5_digests = [] | |
with open(inputfile, 'rb') as f: | |
for chunk in iter(lambda: f.read(partsize), b''): | |
md5_digests.append(md5(chunk).digest()) | |
return md5(b''.join(md5_digests)).hexdigest() + '-' + str(len(md5_digests)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment