本文整理匯總了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();
}