Search in sources :

Example 56 with AmazonS3Client

use of com.amazonaws.services.s3.AmazonS3Client in project exhibitor by soabase.

the class S3ClientImpl method uploadPart.

@Override
public UploadPartResult uploadPart(UploadPartRequest request) throws Exception {
    RefCountedClient holder = client.get();
    AmazonS3Client amazonS3Client = holder.useClient();
    try {
        return amazonS3Client.uploadPart(request);
    } finally {
        holder.release();
    }
}
Also used : AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client)

Example 57 with AmazonS3Client

use of com.amazonaws.services.s3.AmazonS3Client in project android-simpl3r by jgilfelt.

the class UploadService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    s3Client = new AmazonS3Client(new BasicAWSCredentials(getString(R.string.s3_access_key), getString(R.string.s3_secret)));
    nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    IntentFilter f = new IntentFilter();
    f.addAction(UPLOAD_CANCELLED_ACTION);
    registerReceiver(uploadCancelReceiver, f);
}
Also used : IntentFilter(android.content.IntentFilter) AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials)

Example 58 with AmazonS3Client

use of com.amazonaws.services.s3.AmazonS3Client in project zeppelin by apache.

the class S3NotebookRepo method init.

public void init(ZeppelinConfiguration conf) throws IOException {
    this.conf = conf;
    bucketName = conf.getS3BucketName();
    user = conf.getS3User();
    rootFolder = user + "/notebook";
    useServerSideEncryption = conf.isS3ServerSideEncryption();
    if (StringUtils.isNotBlank(conf.getS3CannedAcl())) {
        objectCannedAcl = CannedAccessControlList.valueOf(conf.getS3CannedAcl());
    }
    // always use the default provider chain
    AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
    CryptoConfiguration cryptoConf = new CryptoConfiguration();
    String keyRegion = conf.getS3KMSKeyRegion();
    if (StringUtils.isNotBlank(keyRegion)) {
        cryptoConf.setAwsKmsRegion(Region.getRegion(Regions.fromName(keyRegion)));
    }
    ClientConfiguration cliConf = createClientConfiguration();
    // see if we should be encrypting data in S3
    String kmsKeyID = conf.getS3KMSKeyID();
    if (kmsKeyID != null) {
        // use the AWS KMS to encrypt data
        KMSEncryptionMaterialsProvider emp = new KMSEncryptionMaterialsProvider(kmsKeyID);
        this.s3client = new AmazonS3EncryptionClient(credentialsProvider, emp, cliConf, cryptoConf);
    } else if (conf.getS3EncryptionMaterialsProviderClass() != null) {
        // use a custom encryption materials provider class
        EncryptionMaterialsProvider emp = createCustomProvider(conf);
        this.s3client = new AmazonS3EncryptionClient(credentialsProvider, emp, cliConf, cryptoConf);
    } else {
        // regular S3
        this.s3client = new AmazonS3Client(credentialsProvider, cliConf);
    }
    s3client.setS3ClientOptions(S3ClientOptions.builder().setPathStyleAccess(conf.isS3PathStyleAccess()).build());
    // set S3 endpoint to use
    s3client.setEndpoint(conf.getS3Endpoint());
}
Also used : DefaultAWSCredentialsProviderChain(com.amazonaws.auth.DefaultAWSCredentialsProviderChain) AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) AmazonS3EncryptionClient(com.amazonaws.services.s3.AmazonS3EncryptionClient) KMSEncryptionMaterialsProvider(com.amazonaws.services.s3.model.KMSEncryptionMaterialsProvider) EncryptionMaterialsProvider(com.amazonaws.services.s3.model.EncryptionMaterialsProvider) KMSEncryptionMaterialsProvider(com.amazonaws.services.s3.model.KMSEncryptionMaterialsProvider) CryptoConfiguration(com.amazonaws.services.s3.model.CryptoConfiguration) AWSCredentialsProvider(com.amazonaws.auth.AWSCredentialsProvider) ClientConfiguration(com.amazonaws.ClientConfiguration)

Example 59 with AmazonS3Client

use of com.amazonaws.services.s3.AmazonS3Client in project h2o-3 by h2oai.

the class PersistS3 method configureClient.

static AmazonS3Client configureClient(AmazonS3Client s3Client) {
    if (System.getProperty(S3_REGION) != null) {
        String region = System.getProperty(S3_REGION);
        Log.debug("S3 region specified: ", region);
        s3Client.setRegion(RegionUtils.getRegion(region));
    }
    // Region overrides end-point settings
    if (System.getProperty(S3_END_POINT) != null) {
        String endPoint = System.getProperty(S3_END_POINT);
        Log.debug("S3 endpoint specified: ", endPoint);
        s3Client.setEndpoint(endPoint);
    }
    if (System.getProperty(S3_ENABLE_PATH_STYLE) != null && Boolean.valueOf(System.getProperty(S3_ENABLE_PATH_STYLE))) {
        Log.debug("S3 path style access enabled");
        S3ClientOptions sco = new S3ClientOptions();
        sco.setPathStyleAccess(true);
        s3Client.setS3ClientOptions(sco);
    }
    return s3Client;
}
Also used : S3ClientOptions(com.amazonaws.services.s3.S3ClientOptions)

Example 60 with AmazonS3Client

use of com.amazonaws.services.s3.AmazonS3Client in project archaius by Netflix.

the class S3ConfigurationSourceTest method setup.

@Before
public void setup() throws Exception {
    fakeS3 = createHttpServer();
    client = new AmazonS3Client(new StaticCredentialsProvider(new AnonymousAWSCredentials()));
    client.setS3ClientOptions(new S3ClientOptions().withPathStyleAccess(true));
    client.setEndpoint("http://localhost:8069");
}
Also used : AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) StaticCredentialsProvider(com.amazonaws.internal.StaticCredentialsProvider) S3ClientOptions(com.amazonaws.services.s3.S3ClientOptions) AnonymousAWSCredentials(com.amazonaws.auth.AnonymousAWSCredentials) Before(org.junit.Before)

Aggregations

AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)109 Test (org.junit.Test)23 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)20 AmazonClientException (com.amazonaws.AmazonClientException)18 ClientConfiguration (com.amazonaws.ClientConfiguration)18 ArrayList (java.util.ArrayList)14 AWSCredentialsProvider (com.amazonaws.auth.AWSCredentialsProvider)13 HashMap (java.util.HashMap)13 AmazonS3 (com.amazonaws.services.s3.AmazonS3)12 File (java.io.File)12 InvocationOnMock (org.mockito.invocation.InvocationOnMock)12 PutObjectResult (com.amazonaws.services.s3.model.PutObjectResult)11 UploadPartRequest (com.amazonaws.services.s3.model.UploadPartRequest)11 AWSCredentials (com.amazonaws.auth.AWSCredentials)10 AmazonS3Exception (com.amazonaws.services.s3.model.AmazonS3Exception)10 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)10 S3Object (com.amazonaws.services.s3.model.S3Object)9 InternalEvent (com.nextdoor.bender.InternalEvent)9 TestContext (com.nextdoor.bender.aws.TestContext)9 IOException (java.io.IOException)9