当前位置: 首页>>代码示例>>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;未经允许,请勿转载。