【发布时间】:2022-01-04 13:36:27
【问题描述】:
我必须从 AmazonS3EncryptionClient 迁移到 AmazonS3EncryptionClientV2,因此我遵循以下说明:https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/s3-encryption-migration.html,但我总是遇到相同的错误,即使设置了区域:“无法通过区域找到区域提供者链。必须在构建器或设置环境中提供显式区域以提供区域。"
AmazonS3 s3Encryption = AmazonS3EncryptionClientV2.encryptionBuilder()
.withRegion(Regions.EU_CENTRAL_1)
.withCredentials(new AWSStaticCredentialsProvider(
new BasicAWSCredentials(AWS_S3_KEY, AWS_S3_SECRET)))
.withCryptoConfiguration(new CryptoConfigurationV2()
// The following setting allows the client to read V1 encrypted objects
.withCryptoMode(CryptoMode.AuthenticatedEncryption)
.withCryptoProvider(new BouncyCastleProvider()))
.withEncryptionMaterialsProvider(new StaticEncryptionMaterialsProvider(
new EncryptionMaterials(createKeyPair(AWS_S3_PRIVATE_KEY,
AWS_S3_PUBLIC_KEY))))
.build();
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.908</version>
</dependency>
有人知道吗?因为当我使用像 AmazonS3ClientBuilder 这样的另一个客户端时,一切正常。
【问题讨论】:
标签: amazon-s3