最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ASP.NET Amazon Storage Object S3 SDK on Ionos - Stack Overflow

programmeradmin10浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论