当前位置: 首页>>代码示例>>Java>>正文


Java AmazonS3ClientBuilder.build方法代码示例

本文整理汇总了Java中com.amazonaws.services.s3.AmazonS3ClientBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonS3ClientBuilder.build方法的具体用法?Java AmazonS3ClientBuilder.build怎么用?Java AmazonS3ClientBuilder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.s3.AmazonS3ClientBuilder的用法示例。


在下文中一共展示了AmazonS3ClientBuilder.build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getS3Client

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
public static AmazonS3Client getS3Client(AuthCredentialsServiceState credentials,
        String regionId) {

    ClientConfiguration configuration = new ClientConfiguration();
    configuration.withRetryPolicy(new RetryPolicy(new CustomRetryCondition(),
            DEFAULT_BACKOFF_STRATEGY,
            DEFAULT_MAX_ERROR_RETRY,
            false));

    AWSStaticCredentialsProvider awsStaticCredentialsProvider = new AWSStaticCredentialsProvider(
            new BasicAWSCredentials(credentials.privateKeyId,
                    EncryptionUtils.decrypt(credentials.privateKey)));

    AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder
            .standard()
            .withClientConfiguration(configuration)
            .withCredentials(awsStaticCredentialsProvider)
            .withRegion(regionId);

    if (isAwsClientMock()) {
        throw new IllegalArgumentException("AWS Mock does not support S3 client");
    }

    return (AmazonS3Client) amazonS3ClientBuilder.build();
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:26,代码来源:AWSUtils.java

示例2: newS3Client

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
public AmazonS3 newS3Client(S3SinkConnectorConfig config) {
  ClientConfiguration clientConfiguration = newClientConfiguration(config);
  AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard()
                                      .withAccelerateModeEnabled(
                                          config.getBoolean(WAN_MODE_CONFIG)
                                      )
                                      .withPathStyleAccessEnabled(true)
                                      .withCredentials(config.getCredentialsProvider())
                                      .withClientConfiguration(clientConfiguration);

  String region = config.getString(REGION_CONFIG);
  if (StringUtils.isBlank(url)) {
    builder = "us-east-1".equals(region)
              ? builder.withRegion(Regions.US_EAST_1)
              : builder.withRegion(region);
  } else {
    builder = builder.withEndpointConfiguration(
        new AwsClientBuilder.EndpointConfiguration(url, region)
    );
  }

  return builder.build();
}
 
开发者ID:confluentinc,项目名称:kafka-connect-storage-cloud,代码行数:24,代码来源:S3Storage.java

示例3: newS3Client

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
@Override
public AmazonS3 newS3Client(S3SinkConnectorConfig config) {
  final AWSCredentialsProvider provider = new AWSCredentialsProvider() {
    private final AnonymousAWSCredentials credentials = new AnonymousAWSCredentials();
    @Override
    public AWSCredentials getCredentials() {
      return credentials;
    }

    @Override
    public void refresh() {
    }
  };

  AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard()
             .withAccelerateModeEnabled(config.getBoolean(S3SinkConnectorConfig.WAN_MODE_CONFIG))
             .withPathStyleAccessEnabled(true)
             .withCredentials(provider);

  builder = url == null ?
                builder.withRegion(config.getString(S3SinkConnectorConfig.REGION_CONFIG)) :
                builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(url, ""));

  return builder.build();
}
 
开发者ID:confluentinc,项目名称:kafka-connect-storage-cloud,代码行数:26,代码来源:TestWithMockedS3.java

示例4: newInstance

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
private AmazonS3 newInstance(String region, S3S3CopierOptions s3s3CopierOptions) {
  HadoopAWSCredentialProviderChain credentialsChain = getCredentialsProviderChain();
  AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard().withCredentials(credentialsChain);
  URI s3Endpoint = s3s3CopierOptions.getS3Endpoint(region);
  if (s3Endpoint != null) {
    EndpointConfiguration endpointConfiguration = new EndpointConfiguration(s3Endpoint.toString(), region);
    builder.withEndpointConfiguration(endpointConfiguration);
  } else {
    builder.withRegion(region);
  }
  return builder.build();
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:13,代码来源:JceksAmazonS3ClientFactory.java

示例5: newGlobalInstance

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
private AmazonS3 newGlobalInstance(S3S3CopierOptions s3s3CopierOptions) {
  HadoopAWSCredentialProviderChain credentialsChain = getCredentialsProviderChain();
  AmazonS3ClientBuilder builder = AmazonS3ClientBuilder
      .standard()
      .withForceGlobalBucketAccessEnabled(Boolean.TRUE)
      .withCredentials(credentialsChain);
  URI s3Endpoint = s3s3CopierOptions.getS3Endpoint();
  if (s3Endpoint != null) {
    EndpointConfiguration endpointConfiguration = new EndpointConfiguration(s3Endpoint.toString(),
        Region.US_Standard.getFirstRegionId());
    builder.withEndpointConfiguration(endpointConfiguration);
  }
  return builder.build();
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:15,代码来源:JceksAmazonS3ClientFactory.java

示例6: newInstance

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
public AmazonS3 newInstance(Configuration conf) {
  int maxErrorRetry = conf.getInt(ConfigurationVariable.UPLOAD_RETRY_COUNT.getName(),
      ConfigurationVariable.UPLOAD_RETRY_COUNT.defaultIntValue());
  long errorRetryDelay = conf.getLong(ConfigurationVariable.UPLOAD_RETRY_DELAY_MS.getName(),
      ConfigurationVariable.UPLOAD_RETRY_DELAY_MS.defaultLongValue());

  LOG.info("Creating AWS S3 client with a retry policy of {} retries and {} ms of exponential backoff delay",
      maxErrorRetry, errorRetryDelay);

  RetryPolicy retryPolicy = new RetryPolicy(new CounterBasedRetryCondition(maxErrorRetry),
      new ExponentialBackoffStrategy(errorRetryDelay), maxErrorRetry, true);
  ClientConfiguration clientConfiguration = new ClientConfiguration();
  clientConfiguration.setRetryPolicy(retryPolicy);
  clientConfiguration.setMaxErrorRetry(maxErrorRetry);

  AmazonS3ClientBuilder builder = AmazonS3ClientBuilder
      .standard()
      .withCredentials(new HadoopAWSCredentialProviderChain(conf))
      .withClientConfiguration(clientConfiguration);

  EndpointConfiguration endpointConfiguration = getEndpointConfiguration(conf);
  if (endpointConfiguration != null) {
    builder.withEndpointConfiguration(endpointConfiguration);
  } else {
    builder.withRegion(getRegion(conf));
  }

  return builder.build();
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:30,代码来源:AwsS3ClientFactory.java

示例7: S3Reader

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
public S3Reader(Region region, String accessKey, String secretKey) {
    AmazonS3ClientBuilder clientBuilder = AmazonS3ClientBuilder.standard();
    clientBuilder.setRegion(region.getName());

    if (!accessKey.isEmpty() && !secretKey.isEmpty()) {
        clientBuilder.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey)));
    }

    this.s3Client = clientBuilder.build();
}
 
开发者ID:sherzberg,项目名称:graylog-plugin-s3,代码行数:11,代码来源:S3Reader.java

示例8: newS3Client

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
public AmazonS3 newS3Client(S3SinkConnectorConfig config) {
  AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard()
             .withAccelerateModeEnabled(config.getBoolean(S3SinkConnectorConfig.WAN_MODE_CONFIG))
             .withPathStyleAccessEnabled(true)
             .withCredentials(new DefaultAWSCredentialsProviderChain());

  builder = url == null ?
                builder.withRegion(config.getString(S3SinkConnectorConfig.REGION_CONFIG)) :
                builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(url, ""));

  return builder.build();
}
 
开发者ID:confluentinc,项目名称:kafka-connect-storage-cloud,代码行数:13,代码来源:S3SinkConnectorTestBase.java

示例9: 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

示例10: create

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
public AmazonS3 create(final BlobStoreConfiguration blobStoreConfiguration) {
  AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();

  String accessKeyId = blobStoreConfiguration.attributes(CONFIG_KEY).get(ACCESS_KEY_ID_KEY, String.class);
  String secretAccessKey = blobStoreConfiguration.attributes(CONFIG_KEY).get(SECRET_ACCESS_KEY_KEY, String.class);
  String region = blobStoreConfiguration.attributes(CONFIG_KEY).get(REGION_KEY, String.class);

  if (!isNullOrEmpty(accessKeyId) && !isNullOrEmpty(secretAccessKey)) {
    String sessionToken = blobStoreConfiguration.attributes(CONFIG_KEY).get(SESSION_TOKEN_KEY, String.class);
    AWSCredentials credentials = buildCredentials(accessKeyId, secretAccessKey, sessionToken);

    String assumeRole = blobStoreConfiguration.attributes(CONFIG_KEY).get(ASSUME_ROLE_KEY, String.class);
    AWSCredentialsProvider credentialsProvider = buildCredentialsProvider(credentials, region, assumeRole);

    builder = builder.withCredentials(credentialsProvider);
  }

  if (!isNullOrEmpty(region)) {
    String endpoint = blobStoreConfiguration.attributes(CONFIG_KEY).get(ENDPOINT_KEY, String.class);
    if (!isNullOrEmpty(endpoint)) {
      builder = builder.withEndpointConfiguration(new AmazonS3ClientBuilder.EndpointConfiguration(endpoint, region));
    } else {
      builder = builder.withRegion(region);
    }
  }

  return builder.build();
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:29,代码来源:AmazonS3Factory.java

示例11: buildClient

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
private AmazonS3 buildClient() {
	ProfileCredentialsProvider credentialsProvider = new ProfileCredentialsProvider(profile);
	AmazonS3ClientBuilder clientBuilder = AmazonS3ClientBuilder.standard();
	clientBuilder.setCredentials(credentialsProvider);
	clientBuilder.setRegion(region);
	return clientBuilder.build();
}
 
开发者ID:labcabrera,项目名称:lab-insurance,代码行数:8,代码来源:InsuranceS3Service.java

示例12: createConnection

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
private void createConnection(
    Stage.Context context,
    String configPrefix,
    ProxyConfig proxyConfig,
    List<Stage.ConfigIssue> issues,
    int maxErrorRetries
) throws StageException {
  AWSCredentialsProvider credentials = AWSUtil.getCredentialsProvider(awsConfig);
  ClientConfiguration clientConfig = AWSUtil.getClientConfiguration(proxyConfig);

  if (maxErrorRetries >= 0) {
    clientConfig.setMaxErrorRetry(maxErrorRetries);
  }

  AmazonS3ClientBuilder builder = AmazonS3ClientBuilder
      .standard()
      .withCredentials(credentials)
      .withClientConfiguration(clientConfig)
      .withChunkedEncodingDisabled(awsConfig.disableChunkedEncoding)
      .withPathStyleAccessEnabled(true);

  if (region == AWSRegions.OTHER) {
    if (endpoint == null || endpoint.isEmpty()) {
      issues.add(context.createConfigIssue(Groups.S3.name(), configPrefix + "endpoint", Errors.S3_SPOOLDIR_10));
      return;
    }
    builder.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, null));
  } else {
    builder.withRegion(region.getLabel());
  }
  s3Client = builder.build();
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:33,代码来源:S3ConnectionBaseConfig.java

示例13: amazonS3

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
@Bean
public AmazonS3 amazonS3(Environment environment, ApplicationContext applicationContext) {
    // Configure authentication
    final String authentication = environment.getProperty("content-service.store.s3.authentication", EC2_AUTHENTICATION)
            .toUpperCase();
    AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();
    switch (authentication) {
    case EC2_AUTHENTICATION:
        builder = configureEC2Authentication(builder);
        break;
    case TOKEN_AUTHENTICATION:
        builder = configureTokenAuthentication(environment, builder);
        break;
    case CUSTOM_AUTHENTICATION:
        try {
            final AmazonS3Provider amazonS3Provider = applicationContext.getBean(AmazonS3Provider.class);
            return amazonS3Provider.getAmazonS3Client();
        } catch (NoSuchBeanDefinitionException e) {
            throw new InvalidConfiguration("No S3 client provider in context", AmazonS3Provider.class, e);
        }
    default:
        throw new IllegalArgumentException("Authentication '" + authentication + "' is not supported.");
    }

    // Configure region (optional)
    final String region = environment.getProperty("content-service.store.s3.region");
    if (StringUtils.isNotBlank(region)) {
        builder = builder.withRegion(region);
    }

    // All set
    return builder.build();
}
 
开发者ID:Talend,项目名称:daikon,代码行数:34,代码来源:S3ContentServiceConfiguration.java

示例14: getS3client

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入方法依赖的package包/类
public static AmazonS3 getS3client(GoEnvironment env) {
    AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder.standard();

    if (env.has(AWS_REGION)) {
        amazonS3ClientBuilder.withRegion(env.get(AWS_REGION));
    }
    if (env.hasAWSUseIamRole()) {
        amazonS3ClientBuilder.withCredentials(new InstanceProfileCredentialsProvider(false));
    } else if (env.has(AWS_ACCESS_KEY_ID) && env.has(AWS_SECRET_ACCESS_KEY)) {
        BasicAWSCredentials basicCreds = new BasicAWSCredentials(env.get(AWS_ACCESS_KEY_ID), env.get(AWS_SECRET_ACCESS_KEY));
        amazonS3ClientBuilder.withCredentials(new AWSStaticCredentialsProvider(basicCreds));
    }

    return amazonS3ClientBuilder.build();
}
 
开发者ID:indix,项目名称:gocd-s3-artifacts,代码行数:16,代码来源:S3ArtifactStore.java

示例15: 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.build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。