Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon S3 gives InvalidDigest: The Content-MD5 you specified was invalid

This is the solution: fix it by converting the MD5 hex to base64 instead of the string.

Example for JS (Node.js or similar, browserify, etc.

new Buffer(md5, 'hex').toString('base64')

I just spent few minutes to figure this out so I thought I could share it. :)

like image 230
alsdkjasdlkja Avatar asked Nov 07 '15 00:11

alsdkjasdlkja


1 Answers

Content-MD5 is always a base64 header.

The base64-encoded 128-bit MD5 digest of the message (without the headers) according to RFC 1864. This header can be used as a message integrity check to verify that the data is the same data that was originally sent. Although it is optional, we recommend using the Content-MD5 mechanism as an end-to-end integrity check. For more information about REST request authentication, go to REST Authentication in the Amazon Simple Storage Service Developer Guide Type: String Default: None Constraints: None

REST Put Object

like image 176
Harshavardhana Avatar answered Sep 19 '22 09:09

Harshavardhana