本文整理汇总了Java中com.amazonaws.services.s3.AmazonS3ClientBuilder.withClientConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonS3ClientBuilder.withClientConfiguration方法的具体用法?Java AmazonS3ClientBuilder.withClientConfiguration怎么用?Java AmazonS3ClientBuilder.withClientConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.AmazonS3ClientBuilder
的用法示例。
在下文中一共展示了AmazonS3ClientBuilder.withClientConfiguration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getS3Client
import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
/**
* Get or initialize the S3 client.
* Note: this method must be synchronized because we're accessing the
* {@link #s3Client} field and we're calling this method from a worker thread.
* @return the S3 client
*/
private synchronized AmazonS3 getS3Client() {
if (s3Client == null) {
BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
AmazonS3ClientBuilder builder = AmazonS3ClientBuilder
.standard()
.withCredentials(new AWSStaticCredentialsProvider(credentials));
if (forceSignatureV2) {
ClientConfigurationFactory configFactory = new ClientConfigurationFactory();
ClientConfiguration config = configFactory.getConfig();
config.setSignerOverride("S3SignerType");
builder = builder.withClientConfiguration(config);
}
String endpoint = "http://" + host + ":" + port;
String clientRegion = null;
if (!ServiceUtils.isS3USStandardEndpoint(endpoint)) {
clientRegion = AwsHostNameUtils.parseRegion(host,
AmazonS3Client.S3_SERVICE_NAME);
}
builder = builder.withEndpointConfiguration(new EndpointConfiguration(
endpoint, clientRegion));
builder = builder.withPathStyleAccessEnabled(pathStyleAccess);
s3Client = builder.build();
}
return s3Client;
}
示例2: S3Reader
import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
public S3Reader(Region region, HttpUrl proxyUrl, AWSAuthProvider authProvider) {
AmazonS3ClientBuilder clientBuilder = AmazonS3ClientBuilder.standard().withRegion(region.getName()).withCredentials(authProvider);
if(proxyUrl != null) {
clientBuilder.withClientConfiguration(Proxy.forAWS(proxyUrl));
}
this.client = clientBuilder.build();
}