當前位置: 首頁>>代碼示例>>Java>>正文


Java AmazonS3ClientBuilder.withClientConfiguration方法代碼示例

本文整理匯總了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;
}
 
開發者ID:georocket,項目名稱:georocket,代碼行數:37,代碼來源:S3Store.java

示例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();
}
 
開發者ID:Graylog2,項目名稱:graylog-plugin-aws,代碼行數:10,代碼來源:S3Reader.java


注:本文中的com.amazonaws.services.s3.AmazonS3ClientBuilder.withClientConfiguration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。