Example usage for com.amazonaws.services.s3 AmazonS3 setS3ClientOptions

List of usage examples for com.amazonaws.services.s3 AmazonS3 setS3ClientOptions

Introduction

In this page you can find the example usage for com.amazonaws.services.s3 AmazonS3 setS3ClientOptions.

Prototype

public void setS3ClientOptions(S3ClientOptions clientOptions);

Source Link

Document

Override the default S3 client options for this client.

Usage

From source file:io.dockstore.common.FileProvisioning.java

License:Apache License

private static AmazonS3 getAmazonS3Client(HierarchicalINIConfiguration config) {
    AmazonS3 s3Client = new AmazonS3Client(new ClientConfiguration().withSignerOverride("S3Signer"));
    if (config.containsKey(S3_ENDPOINT)) {
        final String endpoint = config.getString(S3_ENDPOINT);
        LOG.info("found custom S3 endpoint, setting to {}", endpoint);
        s3Client.setEndpoint(endpoint);/*from  www  . j a va  2 s.  co m*/
        s3Client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true));
    }
    return s3Client;
}

From source file:org.caboclo.clients.AmazonClient.java

License:Open Source License

private AmazonS3 getS3_() throws AmazonClientException {
    AmazonS3 s3_;
    S3ClientOptions s3ClientOptions;//from   w  w w .  j  ava 2s .  c  o m
    //        AWSCredentials credentials = new BasicAWSCredentials(Constants.EC2_ACCESS_KEY, Constants.EC2_SECRET_KEY);

    AWSCredentials credentials = new BasicAWSCredentials(getAuthenticationParameter(ACCESS_KEY),
            getAuthenticationParameter(SECRET_KEY));

    s3_ = new AmazonS3Client(credentials);
    s3ClientOptions = new S3ClientOptions();
    //s3_.setEndpoint(Constants.EC2_END_POINT);
    s3ClientOptions.setPathStyleAccess(true);
    s3_.setS3ClientOptions(s3ClientOptions);
    System.out.println(s3_.listBuckets());
    return s3_;
}

From source file:org.geoserver.taskmanager.external.impl.S3FileServiceImpl.java

License:Open Source License

private AmazonS3 getS3Client() {
    if (endpoint == null) {
        throw new IllegalArgumentException("The endpoint is required, add a property: alias.s3.endpoint");
    }//from  w  ww .  j  a v  a2s .  c om
    if (user == null) {
        throw new IllegalArgumentException("The user is required, add a property: alias.s3.user");
    }
    if (password == null) {
        throw new IllegalArgumentException("The password is required, add a property: alias.s3.password");
    }
    if (rootFolder == null) {
        throw new IllegalStateException("The rootfolder is required, add a property: alias.s3.rootfolder");
    }

    AmazonS3 s3;
    // custom endpoint

    s3 = new AmazonS3Client(new BasicAWSCredentials(user, password));

    final S3ClientOptions clientOptions = S3ClientOptions.builder().setPathStyleAccess(true).build();
    s3.setS3ClientOptions(clientOptions);
    String endpoint = this.endpoint;
    if (!endpoint.endsWith("/")) {
        endpoint = endpoint + "/";
    }
    s3.setEndpoint(endpoint);

    return s3;
}

From source file:org.whispersystems.textsecuregcm.s3.UrlSigner.java

License:Open Source License

public URL getPreSignedUrl(long attachmentId, HttpMethod method) {
    AmazonS3 client = new AmazonS3Client(credentials);
    GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(bucket, String.valueOf(attachmentId),
            method);/*from   ww  w.  j  ava 2 s. c o  m*/

    request.setExpiration(new Date(System.currentTimeMillis() + DURATION));
    request.setContentType("application/octet-stream");

    client.setS3ClientOptions(S3ClientOptions.builder().setAccelerateModeEnabled(true).build());

    return client.generatePresignedUrl(request);
}