0

I'm using the AWSSDK.S3 for .NET (v4.0.9.1) in my app. For my tests I run minio in a docker container. I know this worked in the past but with an update to the current versions of the SDK and the docker image I get this exception

Amazon.S3.AmazonS3Exception: The provided 'x-amz-content-sha256' header does not match what was computed.

when I try to upload a file via one of the extension methods from the SDK

IAmazonS3 s3 = ...;
await s3.UploadObjectFromStreamAsync(
    bucketName,
    objectKey,
    stream,
    new Dictionary<string, object>(),
    cancellationToken);

I tried to turn off the checksum validation via the AmazonS3Config but that did not solve the problem.

Any ideas what I'm missing? Since this is for tests only I don't care all that much if a solution is potentially "dangerous" and should not be applied in production code.

1 Answer 1

0

you can disable new Sigv4 signing:

using Amazon;
using Amazon.Runtime;
using Amazon.S3;

var request = new PutObjectRequest
{
    FilePath = @"/path/file.txt",
    BucketName = "theBucket",
    DisablePayloadSigning = true,           // sigv4 is introduced in the new s3 sdk
    DisableDefaultChecksumValidation = true // need to disable it until you migrate
};

var response = await s3Client.PutObjectAsync(request);

Console.WriteLine("ETag: {0}", response.ETag);

https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html

Sign up to request clarification or add additional context in comments.

1 Comment

Unfortunately that would require HTTPS Amazon.Runtime.AmazonClientException: When DisablePayloadSigning is true, the request must be sent over HTTPS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.