Search in sources :

Example 46 with S3Client

use of uk.co.automatictester.lightning.lambda.s3.S3Client in project aws-doc-sdk-examples by awsdocs.

the class S3Service method getClient.

// Create the S3Client object.
private S3Client getClient() {
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().credentialsProvider(EnvironmentVariableCredentialsProvider.create()).region(region).build();
    return s3;
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 47 with S3Client

use of uk.co.automatictester.lightning.lambda.s3.S3Client in project aws-doc-sdk-examples by awsdocs.

the class GetAcl method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "  <bucketName> <objectKey>\n\n" + "Where:\n" + "  bucketName - the Amazon S3 bucket to get the access control list (ACL) for.\n" + "  objectKey - the object to get the ACL for. \n";
    if (args.length != 2) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    String objectKey = args[1];
    System.out.println("Retrieving ACL for object: " + objectKey);
    System.out.println("in bucket: " + bucketName);
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();
    getBucketACL(s3, objectKey, bucketName);
    s3.close();
    System.out.println("Done!");
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 48 with S3Client

use of uk.co.automatictester.lightning.lambda.s3.S3Client in project aws-doc-sdk-examples by awsdocs.

the class GetObjectContentType method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <bucketName> <keyName>>\n\n" + "Where:\n" + "    bucketName - the Amazon S3 bucket name. \n\n" + "    keyName - the key name. \n\n";
    if (args.length != 2) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    String keyName = args[1];
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();
    getContentType(s3, bucketName, keyName);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 49 with S3Client

use of uk.co.automatictester.lightning.lambda.s3.S3Client in project aws-doc-sdk-examples by awsdocs.

the class ListObjects method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <bucketName> \n\n" + "Where:\n" + "    bucketName - the Amazon S3 bucket from which objects are read. \n\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();
    listBucketObjects(s3, bucketName);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 50 with S3Client

use of uk.co.automatictester.lightning.lambda.s3.S3Client in project aws-doc-sdk-examples by awsdocs.

the class GetBucketPolicy method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <bucketName>\n\n" + "Where:\n" + "    bucketName - the Amazon S3 bucket to get the policy from.\n\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    System.out.format("Getting policy for bucket: \"%s\"\n\n", bucketName);
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();
    String polText = getPolicy(s3, bucketName);
    System.out.println("Policy Text: " + polText);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Aggregations

S3Client (software.amazon.awssdk.services.s3.S3Client)63 Region (software.amazon.awssdk.regions.Region)43 S3Exception (software.amazon.awssdk.services.s3.model.S3Exception)8 S3Object (software.amazon.awssdk.services.s3.model.S3Object)7 List (java.util.List)5 GetObjectRequest (software.amazon.awssdk.services.s3.model.GetObjectRequest)5 GetObjectResponse (software.amazon.awssdk.services.s3.model.GetObjectResponse)5 SupplierEx (com.hazelcast.function.SupplierEx)4 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)3 S3ClientBuilder (software.amazon.awssdk.services.s3.S3ClientBuilder)3 Pipeline (com.hazelcast.jet.pipeline.Pipeline)2 TestSources (com.hazelcast.jet.pipeline.test.TestSources)2 ILogger (com.hazelcast.logging.ILogger)2 Logger (com.hazelcast.logging.Logger)2 HazelcastSerialClassRunner (com.hazelcast.test.HazelcastSerialClassRunner)2 Collectors (java.util.stream.Collectors)2 AfterClass (org.junit.AfterClass)2 Test (org.junit.Test)2