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


Java AmazonS3ClientBuilder类代码示例

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


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

示例1: amazonS3Client

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入依赖的package包/类
/**
 * S3 储存客户端
 *
 * @return 客户端
 */
@Bean
@ConditionalOnProperty(value = "bigbug.storage.s3.enable", havingValue = "true")
AmazonS3Client amazonS3Client() {
    ClientConfiguration clientConfig = new ClientConfiguration();
    clientConfig.setProtocol(Protocol.HTTP);

    BasicAWSCredentials basicAWSCredentials =
            new BasicAWSCredentials(
                    storageProperties.getStorage().getS3().getAccessKey(),
                    storageProperties.getStorage().getS3().getSecretKey());

    return (AmazonS3Client) AmazonS3ClientBuilder.standard()
            .withClientConfiguration(clientConfig)
            .withEndpointConfiguration(
                    new AwsClientBuilder.EndpointConfiguration(
                            storageProperties.getStorage().getS3().getEndpoint(), Regions.DEFAULT_REGION.getName()))
            .withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials))
            .build();
}
 
开发者ID:bigbug-studio,项目名称:generator-jhipster-storage,代码行数:25,代码来源:_StorageConfiguration.java

示例2: getS3Client

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入依赖的package包/类
public static AmazonS3 getS3Client(final String region, final String roleArn) {
    final Regions awsRegion = StringUtils.isNullOrEmpty(region) ? Regions.US_EAST_1 : Regions.fromName(region);

    if (StringUtils.isNullOrEmpty(roleArn)) {
        return AmazonS3ClientBuilder.standard().withRegion(awsRegion).build();
    } else {
        final AssumeRoleRequest assumeRole = new AssumeRoleRequest().withRoleArn(roleArn).withRoleSessionName("io-klerch-mp3-converter");

        final AWSSecurityTokenService sts = AWSSecurityTokenServiceClientBuilder.standard().withRegion(awsRegion).build();
        final Credentials credentials = sts.assumeRole(assumeRole).getCredentials();

        final BasicSessionCredentials sessionCredentials = new BasicSessionCredentials(
                credentials.getAccessKeyId(),
                credentials.getSecretAccessKey(),
                credentials.getSessionToken());

        return AmazonS3ClientBuilder.standard().withRegion(awsRegion).withCredentials(new AWSStaticCredentialsProvider(sessionCredentials)).build();
    }
}
 
开发者ID:KayLerch,项目名称:alexa-meets-polly,代码行数:20,代码来源:ConvertService.java

示例3: setup

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入依赖的package包/类
@Before
public void setup() throws IllegalAccessException, NoSuchFieldException {

	Assume.assumeTrue(System.getProperty("skip.long") == null);
	TestUtils.disableSslCertChecking();

	amazonS3Client = AmazonS3ClientBuilder.standard()
			.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(
					LocalstackTestRunner.getEndpointS3(),
					LocalstackTestRunner.getDefaultRegion()))
			.withChunkedEncodingDisabled(true)
			.withPathStyleAccessEnabled(true).build();
	amazonS3Client.createBucket(bucketName);

	S3Config config = new S3Config();

	Field field = StorageServiceImpl.class.getDeclaredField("s3TransferManager");
	field.setAccessible(true);
	field.set(underTest, config.s3TransferManager(amazonS3Client));

	field = StorageServiceImpl.class.getDeclaredField("environment");
	field.setAccessible(true);
	field.set(underTest, environment);
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:25,代码来源:StorageServiceImplIntegration.java

示例4: S3Writer

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入依赖的package包/类
public S3Writer(Replicator replicator) {
  this.replicator = replicator;
  this.client =
    AmazonS3ClientBuilder.standard().withRegion(replicator.getConfig().s3.region).build();
  this.copier = Executors.newFixedThreadPool(replicator.getConfig().redshift.maxConnections);
  int queueSize = TABLE_QUEUE_SIZE / replicator.getConfig().tables.size();
  queueSum = queueSize * replicator.getConfig().tables.size();

  for (Config.Table table : replicator.getConfig().tables) {
    copyQueues.put(table.name, new LinkedBlockingQueue<>(queueSize));

    // We only allow 1 copy worker at a time to be copying to a given table, so we maintain this mapping.
    tableCopyLocks.put(table.name, new ReentrantLock());
    uploadFormat(table);
  }

  for (int i = 0; i != replicator.getConfig().redshift.maxConnections; i++) {
    this.copier.submit(new CopyWorker(this, copyQueues, tableCopyLocks));
  }
  this.uploader =
    new ThreadPoolExecutor(1, 100, 30L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(20));
}
 
开发者ID:Patreon,项目名称:euphrates,代码行数:23,代码来源:S3Writer.java

示例5: getS3Value

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入依赖的package包/类
/**
 * Attempt to fetch a secret from S3.
 *
 * @param s3path where to fetch it from
 * @return the content of the file found on S3
 * @throws IOException on problems streaming the content of the file
 * @throws AmazonS3Exception on problems communicating with amazon
 */
private String getS3Value(final SecretPath s3path) throws IOException, AmazonS3Exception {
    LOG.info("Fetching secret from s3://" + s3path.bucket + "/" + s3path.key);
    if (s3Client == null) {
        if (awsCredentialsProvider != null) {
            s3Client = AmazonS3ClientBuilder.standard().withCredentials(awsCredentialsProvider)
                    .build();
        } else {
            s3Client = AmazonS3ClientBuilder.standard().build();
        }
    }
    final S3Object s3object
            = s3Client.getObject(new GetObjectRequest(s3path.bucket, s3path.key));
    final BufferedReader reader
            = new BufferedReader(new InputStreamReader(s3object.getObjectContent()));
    final StringBuilder b = new StringBuilder();
    String line;
    while((line = reader.readLine()) != null) {
        b.append(line);
    }
    LOG.info("Found secret");
    reader.close();
    return b.toString();
}
 
开发者ID:secondbase,项目名称:secondbase,代码行数:32,代码来源:S3SecretHandler.java

示例6: setupS3

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入依赖的package包/类
@BeforeClass
public static void setupS3() {
    final ProfileCredentialsProvider credentialsProvider
            = new ProfileCredentialsProvider(System.getenv("AWS_PROFILE"));
    s3Client = AmazonS3ClientBuilder.standard().withCredentials(credentialsProvider).build();
    bucket = System.getenv("AWS_S3_BUCKET");
    if (! s3Client.doesBucketExist(bucket)) {
        if (System.getenv("AWS_S3_CREATE_BUCKET") == null
                || !Boolean.parseBoolean(System.getenv("AWS_S3_CREATE_BUCKET"))) {
            throw new IllegalStateException("Bucket does not exist and not allowed to create.");
        }
        s3Client.createBucket(bucket);
    }
    S3SecretHandler.setS3CredentialsProvider(credentialsProvider);
    secretHandler = new S3SecretHandler();
}
 
开发者ID:secondbase,项目名称:secondbase,代码行数:17,代码来源:SecretS3IT.java

示例7: LinkGeneratorLambdaHandler

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入依赖的package包/类
LinkGeneratorLambdaHandler(String region, String jwtEncryptKeyArn, String pageStorageBucket, String authVerifyEndpointURL,
                           AWSCredentialsProvider awsCredential, String introPageTemplateName) throws IOException, TemplateException {
    AWSKMS kmsClient = AWSKMSClientBuilder.standard()
            .withCredentials(awsCredential)
            .withRegion(region)
            .build();
    AmazonS3 s3client = AmazonS3ClientBuilder
            .standard()
            .withCredentials(awsCredential)
            .withRegion(region)
            .build();
    kmsEncrypt = new KMSEncrypt(kmsClient, jwtEncryptKeyArn);
    this.pageStorageBucket = pageStorageBucket;
    this.authVerifyEndpointURL = authVerifyEndpointURL;
    this.pageUploader = new PageUploader(s3client, pageStorageBucket);


    this.introPageTemplate = new IntroPageTemplate(introPageTemplateName);
}
 
开发者ID:julianghionoiu,项目名称:tdl-auth,代码行数:20,代码来源:LinkGeneratorLambdaHandler.java

示例8: TextToSpeechConverter

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入依赖的package包/类
public TextToSpeechConverter(final AlexaInput input) {
    // the locale is coming with the speechlet request and indicates to source language to translate from
    this.locale = input.getLocale();
    // get translator
    this.translator = TranslatorFactory.getTranslator(this.locale);
    // the language is taken from the user input (slot value) and indicates to language to translate to
    this.language = input.getSlotValue("language");
    final ResourceUtteranceReader reader = new ResourceUtteranceReader("/out", "/voices.yml");
    // the yaml reader reads values from YAML file to get a Polly voiceId for a language
    this.yamlReader = new YamlReader(reader, locale);
    // Polly client to request speech of a translated text
    this.awsPolly = AmazonPollyClientBuilder.standard().build();
    // S3 client to store MP3 with speech of a translated text
    this.awsS3 = AmazonS3ClientBuilder.standard().build();
    // session state handler to read/write skill state information to Alexa session
    this.sessionStateHandler = input.getSessionStateHandler();
    // dynamo state handler to read/write skill state information to DynamoDB
    this.dynamoStateHandler = new AWSDynamoStateHandler(input.getSessionStateHandler().getSession(), SkillConfig.getDynamoTableName());
    // retrieve voiceId from YAML file that maps to the language given by the user
    voiceId = language != null ? yamlReader.getRandomUtterance(language.toLowerCase().replace(" ", "_")).orElse("") : "";
    // language-specific prefix phrases that accidently made it into the text slot and should be removed
    prefixesToRemove = yamlReader.getUtterances("PREFIXES_TO_REMOVE");
}
 
开发者ID:KayLerch,项目名称:alexa-meets-polly,代码行数:24,代码来源:TextToSpeechConverter.java

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

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

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

示例12: getWebsiteConfig

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入依赖的package包/类
public static void getWebsiteConfig(String bucket_name)
{
    final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
    try {
        BucketWebsiteConfiguration config =
            s3.getBucketWebsiteConfiguration(bucket_name);
        if (config == null) {
            System.out.println("No website configuration found!");
        } else {
            System.out.format("Index document: %s\n",
                config.getIndexDocumentSuffix());
            System.out.format("Error document: %s\n",
                config.getErrorDocument());
        }
    } catch (AmazonServiceException e) {
        System.err.println(e.getErrorMessage());
        System.out.println("Failed to get website configuration!");
        System.exit(1);
    }
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:21,代码来源:GetWebsiteConfiguration.java

示例13: authenticatedEncryption_CustomerManagedKey

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入依赖的package包/类
/**
 * Uses AES/GCM with AESWrap key wrapping to encrypt the key. Uses v2 metadata schema. Note that authenticated
 * encryption requires the bouncy castle provider to be on the classpath. Also, for authenticated encryption the size
 * of the data can be no longer than 64 GB.
 */
public void authenticatedEncryption_CustomerManagedKey() throws NoSuchAlgorithmException {
    SecretKey secretKey = KeyGenerator.getInstance("AES").generateKey();
    AmazonS3Encryption s3Encryption = AmazonS3EncryptionClientBuilder
            .standard()
            .withRegion(Regions.US_WEST_2)
            .withCryptoConfiguration(new CryptoConfiguration(CryptoMode.AuthenticatedEncryption))
            .withEncryptionMaterials(new StaticEncryptionMaterialsProvider(new EncryptionMaterials(secretKey)))
            .build();
    
    AmazonS3 s3NonEncrypt = AmazonS3ClientBuilder.defaultClient();

    s3Encryption.putObject(BUCKET_NAME, ENCRYPTED_KEY, "some contents");
    s3NonEncrypt.putObject(BUCKET_NAME, NON_ENCRYPTED_KEY, "some other contents");
    System.out.println(s3Encryption.getObjectAsString(BUCKET_NAME, ENCRYPTED_KEY));
    System.out.println(s3Encryption.getObjectAsString(BUCKET_NAME, NON_ENCRYPTED_KEY));
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:22,代码来源:S3Encrypt.java

示例14: authenticatedEncryption_RangeGet_CustomerManagedKey

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入依赖的package包/类
/**
 * For ranged GET we do not use authenticated encryption since we aren't reading the entire message and can't produce the
 * MAC. Instead we use AES/CTR, an unauthenticated encryption algorithm. If {@link CryptoMode#StrictAuthenticatedEncryption}
 * is enabled, ranged GETs will not be allowed since they do not use authenticated encryption..
 */
public void authenticatedEncryption_RangeGet_CustomerManagedKey() throws NoSuchAlgorithmException {
    SecretKey secretKey = KeyGenerator.getInstance("AES").generateKey();
    AmazonS3Encryption s3Encryption = AmazonS3EncryptionClientBuilder
            .standard()
            .withRegion(Regions.US_WEST_2)
            .withCryptoConfiguration(new CryptoConfiguration(CryptoMode.AuthenticatedEncryption))
            .withEncryptionMaterials(new StaticEncryptionMaterialsProvider(new EncryptionMaterials(secretKey)))
            .build();

    AmazonS3 s3NonEncrypt = AmazonS3ClientBuilder.defaultClient();

    s3Encryption.putObject(BUCKET_NAME, ENCRYPTED_KEY, "some contents");
    s3NonEncrypt.putObject(BUCKET_NAME, NON_ENCRYPTED_KEY, "some other contents");
    System.out.println(s3Encryption.getObjectAsString(BUCKET_NAME, ENCRYPTED_KEY));
    System.out.println(s3Encryption.getObjectAsString(BUCKET_NAME, NON_ENCRYPTED_KEY));
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:22,代码来源:S3Encrypt.java

示例15: authenticatedEncryption_CustomerManagedAsymmetricKey

import com.amazonaws.services.s3.AmazonS3ClientBuilder; //导入依赖的package包/类
/**
 * Same as {@link #authenticatedEncryption_CustomerManagedKey()} except uses an asymmetric key pair and
 * RSA/ECB/OAEPWithSHA-256AndMGF1Padding as the key wrapping algorithm.
 */
public void authenticatedEncryption_CustomerManagedAsymmetricKey() throws NoSuchAlgorithmException {
    KeyPair keyPair = KeyPairGenerator.getInstance("RSA").generateKeyPair();
    AmazonS3Encryption s3Encryption = AmazonS3EncryptionClientBuilder
            .standard()
            .withRegion(Regions.US_WEST_2)
            .withCryptoConfiguration(new CryptoConfiguration(CryptoMode.AuthenticatedEncryption))
            .withEncryptionMaterials(new StaticEncryptionMaterialsProvider(new EncryptionMaterials(keyPair)))
            .build();

    AmazonS3 s3NonEncrypt = AmazonS3ClientBuilder.defaultClient();

    s3Encryption.putObject(BUCKET_NAME, ENCRYPTED_KEY, "some contents");
    s3NonEncrypt.putObject(BUCKET_NAME, NON_ENCRYPTED_KEY, "some other contents");
    System.out.println(s3Encryption.getObjectAsString(BUCKET_NAME, ENCRYPTED_KEY));
    System.out.println(s3Encryption.getObjectAsString(BUCKET_NAME, NON_ENCRYPTED_KEY));
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:21,代码来源:S3Encrypt.java


注:本文中的com.amazonaws.services.s3.AmazonS3ClientBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。