Hello,
How can I retrieve the content MD5 metadata of an existing S3 object? I tried to call com.amazonaws.services.s3.AmazonS3Client.GetObjectMetadata() to get the ObjectMetadata object. But its getContentMD5() method always returns null after GetObjectMetadata() is called.
If it is not possible for now, can you please add this support? Thank you.
Thomas
This is an side effect of sharing the same object between Request and Responses.
As per the S3 documentation
http://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html an MD5 of the object is returned by S3 in "ETag" and not the "Content-MD5" header.
So, you should see the MD5 when you call the getEtag method on the metadata object.
I understand. Thank you. This workaround is ok. I am doing the Hex to Base64 conversion myself. Yet, it'd be great to have the getContentMD5 return the MD5 value in the same format (Base64) as it is supplied to setContentMD5. Now getETag returns the MD5 value as a hex string.
@manikandanrs But the getETag() method is not guaranteed to return the original MD5 if the file was multi-part uploaded right? It will return a re-calculated value based upon the individual chunks's checksum. For data integrity purpose, is it possible to add support to return the original checksum via getContentMD5? The current implementation makes it really hard for the file receiver to resolve the original checksum. Thanks!
Most helpful comment
@manikandanrs But the
getETag()method is not guaranteed to return the original MD5 if the file was multi-part uploaded right? It will return a re-calculated value based upon the individual chunks's checksum. For data integrity purpose, is it possible to add support to return the original checksum viagetContentMD5? The current implementation makes it really hard for the file receiver to resolve the original checksum. Thanks!