unable to send data from ec2 to s3 bucket that is configured with object lock

689 views Asked by At

I am trying to setup s3cmd to send data to s3 bucket that is configured with object lock, but i am getting below error message.

s3 error: 400 (invalidrequest): content-md5 http header is required for put object requests with object lock parameters

Can somebody help me with it?

4

There are 4 answers

0
kgiannakakis On

As you can read at the end note here:

If you configure a default retention period on a bucket, requests to upload objects in such a bucket must include the Content-MD5 header. For more information, see Put Object in the Amazon Simple Storage Service API Reference.

For s3cmd you can use the option:

--add-header=Content-MD5:VALUE

You need to calculate the value somehow, before sending the request.

0
Ping Woo On

You can disable retention with the object lock enabled.

0
furydrive On

Faced this problem today and solved it by adding

-CalculateContentMD5Header $true

I am using AWS Tools for Powershell in this case,

Write-S3Object -BucketName test-files -Key "sample.txt" -File .\local-sample.txt -CalculateContentMD5Header $true

leaving it here in case it helps someone.

0
flob On

You could calculate the MD5 and set it as the header, file by file:

s3cmd put --add-header="Content-MD5: "`cat your-file | openssl dgst -md5 -binary | openssl enc -base64` your-file s3://bucket