Search in sources :

Example 6 with S3Client

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

the class S3BucketDeletion method main.

public static void main(String[] args) throws Exception {
    final String USAGE = "\n" + "Usage:\n" + "    <bucket>\n\n" + "Where:\n" + "    bucket - the bucket to delete (for example, bucket1). \n\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucket = args[0];
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();
    listAllObjects(s3, bucket);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 7 with S3Client

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

the class S3Cors method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "  <bucketName> <accountId> \n\n" + "Where:\n" + "  bucketName - the Amazon S3 bucket to upload an object into.\n" + "  accountId - the id of the account that owns the Amazon S3 bucket.\n";
    ;
    String bucketName = args[0];
    String accountId = args[1];
    Region region = Region.US_EAST_1;
    S3Client s3 = S3Client.builder().region(region).build();
    setCorsInformation(s3, bucketName, accountId);
    getBucketCorsInformation(s3, bucketName, accountId);
    deleteBucketCorsInformation(s3, bucketName, accountId);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 8 with S3Client

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

the class SetAcl method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "  <bucketName> <id> \n\n" + "Where:\n" + "  bucketName - the Amazon S3 bucket to grant permissions on. \n" + "  id - the ID of the owner of this bucket (you can get this value from the AWS Management Console).\n";
    if (args.length != 3) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    String id = args[1];
    System.out.format("Setting access \n");
    System.out.println(" in bucket: " + bucketName);
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();
    setBucketAcl(s3, bucketName, id);
    System.out.println("Done!");
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 9 with S3Client

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

the class SetBucketPolicy method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <bucketName> <polFile>\n\n" + "Where:\n" + "    bucketName - the Amazon S3 bucket to set the policy on.\n" + "    polFile - a JSON file containing the policy (see the Amazon S3 Readme for an example). \n";
    if (args.length != 2) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    String polFile = args[1];
    String policyText = getBucketPolicyFromFile(polFile);
    Region region = Region.US_EAST_1;
    S3Client s3 = S3Client.builder().region(region).build();
    setPolicy(s3, bucketName, policyText);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 10 with S3Client

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

the class PutBucketLogging method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "  <bucketName> <targetBucket>  \n\n" + "Where:\n" + "  bucketName - the Amazon S3 bucket to upload an object into.\n" + "  targetBucket - the target bucket .\n";
    if (args.length != 3) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    String targetBucket = args[1];
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();
    setlogRequest(s3, bucketName, targetBucket);
    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