boto get md5 s3 file

Question:

I have a use case where I upload hundreds of file to my S3 bucket using multi part upload. After each upload I need to make sure that the uploaded file is not corrupt (basically check for data integrity). Currently, after uploading the file, I re-download it and compute the md5 on the content string and compare it with the md5 of local file. So something like:

This approach is wasteful as it doubles the bandwidth usage. I tried

but both return None.

Is there any other way to achieve md5 without downloading the whole thing?

Answer:

yes
use bucket.get_key('file_name').etag[1 :-1]
this way get key’s MD5 without downloading it’s contents.

Leave a Reply