Wei Zhu
Wei Zhu

Reputation: 647

what is the difference getContentMd5() and getETag() of aws s3 PutObjectResult

getEtag() seems to return base64 encoded md5. So what does getContentMd5 return? How are they related?

One example:

 getContentMd5() -> /yoLi66uT7Q6qaverVTqrQ==
 getEtag() -> ff2a0b8baeae4fb43aa9abdead54eaad

Upvotes: 0

Views: 1314

Answers (1)

Michael - sqlbot
Michael - sqlbot

Reputation: 179284

It's the same value -- the md5 hash of the object -- encoded two different ways.

An MD5 hash consists of 16 bytes, but they are not all printable characters. The ETag is the md5 hash, hex-encoded (not base64, as the question suggests) -- hex encoding uses 32 characters to encode 16 bytes.

Meanwhile, Content-MD5 is the md5 hash, base64 encoded, which uses 24 characters to encode 16 bytes.

Upvotes: 2

Related Questions