Search in sources :

Example 56 with S3Client

use of org.jclouds.s3.S3Client in project aws-doc-sdk-examples by awsdocs.

the class CopyObject method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <objectKey> <fromBucket> <toBucket>\n\n" + "Where:\n" + "    objectKey - the name of the object (for example, book.pdf).\n\n" + "    fromBucket - the S3 bucket name that contains the object (for example, bucket1).\n" + "    toBucket - the S3 bucket to copy the object to (for example, bucket2).\n";
    if (args.length != 3) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String objectKey = args[0];
    String fromBucket = args[1];
    String toBucket = args[2];
    System.out.format("Copying object %s from bucket %s to %s\n", objectKey, fromBucket, toBucket);
    Region region = Region.US_EAST_1;
    S3Client s3 = S3Client.builder().region(region).build();
    copyBucketObject(s3, fromBucket, objectKey, toBucket);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 57 with S3Client

use of org.jclouds.s3.S3Client in project aws-doc-sdk-examples by awsdocs.

the class CreateBucket method main.

public static void main(String[] args) throws URISyntaxException {
    final String USAGE = "\n" + "Usage:\n" + "    <bucketName> \n\n" + "Where:\n" + "    bucketName - the name of the bucket to create. The bucket name must be unique, or an error occurs.\n\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    System.out.format("Creating a bucket named %s\n", bucketName);
    Region region = Region.US_EAST_1;
    S3Client s3 = S3Client.builder().region(region).build();
    createBucket(s3, bucketName);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 58 with S3Client

use of org.jclouds.s3.S3Client in project aws-doc-sdk-examples by awsdocs.

the class DeleteBucketPolicy 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 delete the policy from (for example, bucket1).";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    System.out.format("Deleting policy from bucket: \"%s\"\n\n", bucketName);
    Region region = Region.US_EAST_1;
    S3Client s3 = S3Client.builder().region(region).build();
    deleteS3BucketPolicy(s3, bucketName);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 59 with S3Client

use of org.jclouds.s3.S3Client in project aws-doc-sdk-examples by awsdocs.

the class S3BucketOps method main.

public static void main(String[] args) {
    // snippet-start:[s3.java2.s3_bucket_ops.region]
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();
    // snippet-end:[s3.java2.s3_bucket_ops.region]
    String bucket = "bucket" + System.currentTimeMillis();
    System.out.println(bucket);
    createBucket(s3, bucket);
    performOperations(s3, bucket);
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 60 with S3Client

use of org.jclouds.s3.S3Client in project aws-doc-sdk-examples by awsdocs.

the class S3Log method main.

public static void main(String[] args) {
    System.out.println("testing logging setup for " + S3Log.class);
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();
    ListBucketsRequest listBucketsRequest = ListBucketsRequest.builder().build();
    ListBucketsResponse listBucketsResponse = s3.listBuckets(listBucketsRequest);
    listBucketsResponse.buckets().stream().forEach(x -> System.out.println(x.name()));
    logger.info("logging level info");
    logger.debug("logging debug stuff");
    logger.warn("logging warning");
    logger.error("logging error");
    logger.fatal("logging fatal");
}
Also used : ListBucketsResponse(software.amazon.awssdk.services.s3.model.ListBucketsResponse) ListBucketsRequest(software.amazon.awssdk.services.s3.model.ListBucketsRequest) Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Aggregations

S3Client (software.amazon.awssdk.services.s3.S3Client)59 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 ArrayList (java.util.ArrayList)4 InputStream (java.io.InputStream)3 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)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 BufferedReader (java.io.BufferedReader)2 InputStreamReader (java.io.InputStreamReader)2 Collectors (java.util.stream.Collectors)2 AfterClass (org.junit.AfterClass)2