node.jsamazon-s3md5pre-signed-url

How to send content md5 header in the presigned url request of node js


I want to check the integrity of the object uploaded to S3.So I want to include the md5 header so whenever soomeone uses that url they should upload only the valid content. FYI: I would get the md5 content from the UI to my service.

const params = {
    Bucket: bucket,
      Key: id,
      Expires: 300,
      Metadata: metadata,
    };

this.s3ClientAccelerate.getSignedUrl('putObject', params);

Solution

  • Just add ContentMD5 like this.

    const params = { Bucket: bucket, Key: id, Expires: 300, Metadata: metadata,ContentMD5: md5, };
    

    And make sure you pass Content-MD5 in headers of client.