有没有办法使用的“公开可读水桶'亚马逊的AWS .NET SDK的AmazonS3客户端无需指定AWS凭据?亚马逊、凭据、水桶、没有办法

2023-09-03 20:29:23 作者:温柔养猫人

我想用亚马逊的.NET SDK访问公开可读水桶,但 AWSClientFactory.CreateAmazonS3Client 方法创建一个 AmazonS3 迫使你输入你的AwsAccessKey和AwsSecretAccessKey。

I would like to use Amazon's .NET SDK for accessing a publicly readable bucket, but the AWSClientFactory.CreateAmazonS3Client method for creating an AmazonS3 forces you to input your AwsAccessKey and AwsSecretAccessKey.

我不希望在我的客户端应用程序包括这些,但我仍然希望使用亚马逊提供的SDK来在S3上访问这些公开可读的对象。

I do not want to include these in my client-side application, but I still want to use the SDK provided by Amazon to access these publicly readable objects on S3.

这可能吗?

推荐答案

我也问过这个问题上的AWS论坛和亚马逊正式员工回答:

I also asked this question on the AWS forum and an official Amazon employee responded:

随着1.3.8.0版本的SDK,你可以通过在访问空   和密钥和SDK将跳过签名过程并尝试   像GetObject的业务作为一个公共操作。

As of the 1.3.8.0 release of the SDK you can pass null for the access and secret key and the SDK will skip the signing process and try the operations like GetObject as a public operation.

规范

值得一提的是,在书面方式时,目前亚马逊.NET SDK的版本为1.3.14,因此传递null作为凭证是目前可能的。

It's worth noting that at the time of writting, the current Amazon .NET SDK is at version '1.3.14', so passing null for the credentials is currently possible.