admin管理员组

文章数量:1387457

I'm using Amazon S3 AWSSDK.S3 For ASP.NET Core (version 3.7.415.17) to connect to Ionos S3 object storage.

I connect without problems and I'm able to get a pre-signed url, but I can't upload a file, I get always an error.

var s3Config = new AmazonS3Config { ServiceURL = "; };
_s3Client = new AmazonS3Client("**AccessKey***", "***SecretKey***", s3Config);


public async Task<string> UploadFileAsync(IFormFile file, string fileName, string? bucketName = null)
{
    using var stream = file.OpenReadStream();

    var request = new PutObjectRequest
    {
        BucketName = bucketName ?? _bucketName,
        Key = fileName,
        InputStream = stream,
        ContentType = file.ContentType
    };

    var response = await _s3Client.PutObjectAsync(request);
    return response.HttpStatusCode == System.Net.HttpStatusCode.OK ? fileName : null;
}

The error code I'm getting is "XAmzContentSHA256Mismatch". (Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.)

I have been reviewing a lot of tutorials and the code is very simple, but maybe there is something I'm missing.

UPDATE I have been trying previous versions just in case and...yes!!! Since version 3.7.412, it doesn't work, it throws the same error. The last version that works is the 3.7.411.7.

Maybe there is some info about this.

本文标签: ASPNET Amazon Storage Object S3 SDK on IonosStack Overflow