在 AWS SDK V1 中,我将我的凭证设置为:
BasicAWSCredentials awsCredentials = new BasicAWSCredentials(Credentials.access_key, Credentials.secret_access_key);
然后将端点设置为:
EndpointConfiguration endpoint = new EndpointConfiguration("<endpoint URL>", "<region>");
然后将客户端创建为:
AmazonS3 s3client = AmazonS3ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
.withEndpointConfiguration(endpoint)
.build();
如何使用 AWS SDK V2 设置相同的客户端?
在此处查看 Javadoc:
看:
端点覆盖
端点覆盖(URI端点覆盖)
配置 SDK 应与之通信的端点。 **
看起来您可以创建一个URI对象并在创建服务客户端时传递它
URI myURI = new URI("<endpoint URL>");
Region region = Region.US_EAST_1;
S3Client s3 = S3Client.builder()
.region(region)
.endpointOverride(myURI)
.build();
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句