Search in sources :

Example 51 with AmazonS3

use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3 in project h2o-2 by h2oai.

the class TypeaheadFileRequest method serveS3.

protected JsonArray serveS3(String filter, int limit) {
    JsonArray array = new JsonArray();
    try {
        AmazonS3 s3 = PersistS3.getClient();
        filter = Strings.nullToEmpty(filter);
        for (Bucket b : s3.listBuckets()) {
            if (b.getName().startsWith(filter))
                array.add(new JsonPrimitive(b.getName()));
            if (array.size() == limit)
                break;
        }
    } catch (IllegalArgumentException xe) {
    }
    return array;
}
Also used : JsonArray(dontweave.gson.JsonArray) AmazonS3(com.amazonaws.services.s3.AmazonS3) Bucket(com.amazonaws.services.s3.model.Bucket) JsonPrimitive(dontweave.gson.JsonPrimitive)

Example 52 with AmazonS3

use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3 in project h2o-2 by h2oai.

the class TypeaheadS3BucketRequest method serve.

@Override
protected JsonArray serve(String filter, int limit) {
    JsonArray array = new JsonArray();
    try {
        AmazonS3 s3 = PersistS3.getClient();
        filter = Strings.nullToEmpty(filter);
        for (Bucket b : s3.listBuckets()) {
            if (b.getName().startsWith(filter))
                array.add(new JsonPrimitive(b.getName()));
            if (array.size() == limit)
                break;
        }
    } catch (IllegalArgumentException xe) {
    }
    return array;
}
Also used : JsonArray(dontweave.gson.JsonArray) AmazonS3(com.amazonaws.services.s3.AmazonS3) Bucket(com.amazonaws.services.s3.model.Bucket) JsonPrimitive(dontweave.gson.JsonPrimitive)

Example 53 with AmazonS3

use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3 in project crate by crate.

the class S3ClientHelperTest method testWithCredentials.

@Test
public void testWithCredentials() throws Exception {
    AmazonS3 s3Client = s3ClientHelper.client(new URI("s3://user:password@host/path"));
    URL url = s3Client.generatePresignedUrl("bucket", "key", new Date(0L));
    assertThat(url.toString(), is("https://bucket.s3.amazonaws.com/key?AWSAccessKeyId=user&Expires=0&Signature=o5V2voSQbVEErsUXId6SssCq9OY%3D"));
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3) URI(java.net.URI) URL(java.net.URL) Date(java.util.Date) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 54 with AmazonS3

use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3 in project deeplearning4j by deeplearning4j.

the class S3Downloader method paginate.

/**
     * Paginates through a bucket's keys invoking the listener 
     * at each key
     * @param bucket the bucket to iterate
     * @param listener the listener
     */
public void paginate(String bucket, BucketKeyListener listener) {
    AmazonS3 s3 = getClient();
    ObjectListing list = s3.listObjects(bucket);
    for (S3ObjectSummary summary : list.getObjectSummaries()) {
        if (listener != null)
            listener.onKey(s3, bucket, summary.getKey());
    }
    while (list.isTruncated()) {
        list = s3.listNextBatchOfObjects(list);
        for (S3ObjectSummary summary : list.getObjectSummaries()) {
            if (listener != null)
                listener.onKey(s3, bucket, summary.getKey());
        }
    }
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3)

Example 55 with AmazonS3

use of com.talend.shaded.com.amazonaws.services.s3.AmazonS3 in project deeplearning4j by deeplearning4j.

the class S3Downloader method listObjects.

/**
     * Simple way of retrieving the listings for a bucket
     * @param bucket the bucket to retrieve listings for
     * @return the object listing for this bucket
     */
public ObjectListing listObjects(String bucket) {
    AmazonS3 s3 = getClient();
    ObjectListing list = s3.listObjects(bucket);
    return list;
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3)

Aggregations

AmazonS3 (com.amazonaws.services.s3.AmazonS3)85 AmazonServiceException (com.amazonaws.AmazonServiceException)16 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)13 ObjectListing (com.amazonaws.services.s3.model.ObjectListing)13 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)12 File (java.io.File)11 Test (org.junit.Test)11 S3Object (com.amazonaws.services.s3.model.S3Object)10 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)7 Bucket (com.amazonaws.services.s3.model.Bucket)7 ArrayList (java.util.ArrayList)7 AWSStaticCredentialsProvider (com.amazonaws.auth.AWSStaticCredentialsProvider)6 AmazonClientException (com.amazonaws.AmazonClientException)5 ClientConfiguration (com.amazonaws.ClientConfiguration)5 Regions (com.amazonaws.regions.Regions)4 AccessControlList (com.amazonaws.services.s3.model.AccessControlList)4 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)4 PutObjectRequest (com.amazonaws.services.s3.model.PutObjectRequest)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Configuration (org.apache.hadoop.conf.Configuration)4