适用于 .NET 的 AWS 开发工具包。不支持您提供的授权机制

AWS SDK for .NET. The authorization mechanism you have provided is not supported

我在发送 ListObjectRequest 时收到下一个错误:

The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256

根据this回答,AmazonS3Config更新如下:

var amazonS3Config = new AmazonS3Config
{
    SignatureVersion = "4",
    ServiceURL = bucketName,
    RegionEndpoint = RegionEndpoint.USEast1,
    SignatureMethod = SigningAlgorithm.HmacSHA256
};

var s3Client = new AmazonS3Client(accessKeyID, secretKey, amazonS3Config);

但我仍然收到此错误。我在这里错过了什么?

谢谢。

尝试使用最新版本的amazonS3 sdk.I当你知道regionEndpoint时认为ServiceUrl不是必需的,我在私有云amazonS3和不知道Region Endpoint时使用它。我可以使用以下代码从亚马逊检索信息。

        var amazonS3Config = new AmazonS3Config();
        // region of FrankPurt is : RegionEndpoint.EUCentral1
        // according to amazonS3 Doc http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
        amazonS3Config.RegionEndpoint = RegionEndpoint.USEast1;

        var s3Client = new AmazonS3Client("your access key", "your secret key", amazonS3Config);
         S3DirectoryInfo dir = new S3DirectoryInfo(s3Client, "your bucket name", "your folder path without bucket name");
        Console.WriteLine(dir.GetFiles().Count());

通过使用它,我可以在欧盟西部 2 地区工作

            AmazonS3Config config = new AmazonS3Config();
            config.SignatureVersion = "4";
            config.RegionEndpoint = Amazon.RegionEndpoint.GetBySystemName("eu-west-2");
            config.SignatureMethod = Amazon.Runtime.SigningAlgorithm.HmacSHA256;

地区应该