Search in sources :

Example 16 with S3Client

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

the class DeleteMultiObjects method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "To run this example, supply the name of an Amazon S3 bucket.\n" + "\n" + "Ex: DeleteMultiObjects <bucketName>\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();
    deleteBucketObjects(s3, bucketName);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 17 with S3Client

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

the class DeleteObjects method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "To run this example, supply the name of an S3 bucket and at least\n" + "one object name (key) to delete.\n" + "\n" + "Ex: <bucketName> <objectName>\n";
    if (args.length != 2) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    String objectName = args[1];
    System.out.println("Deleting an object from the Amazon S3 bucket: " + bucketName);
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();
    deleteBucketObjects(s3, bucketName, objectName);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 18 with S3Client

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

the class GetObjectUrl 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 - a key name that represents the object. \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();
    getURL(s3, bucketName, keyName);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 19 with S3Client

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

the class LifecycleConfiguration method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "  <bucketName> <accountId> \n\n" + "Where:\n" + "  bucketName - the Amazon Simple Storage Service (Amazon S3) bucket to upload an object into.\n" + "  accountId - the id of the account that owns the Amazon S3 bucket.\n";
    if (args.length != 2) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    String accountId = args[1];
    Region region = Region.US_EAST_1;
    S3Client s3 = S3Client.builder().region(region).build();
    setLifecycleConfig(s3, bucketName, accountId);
    getLifecycleConfig(s3, bucketName, accountId);
    deleteLifecycleConfig(s3, bucketName, accountId);
    System.out.println("You have successfully created, updated, and deleted a Lifecycle configuration ");
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 20 with S3Client

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

the class AbortMultipartUpload method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "  <bucketName> <accountId> \n\n" + "Where:\n" + "  bucketName - the Amazon Simple Storage Service (Amazon S3) bucket.\n" + "  accountId - the id of the account that owns the Amazon S3 bucket.\n";
    if (args.length != 2) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    String accountId = args[1];
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();
    abortUploads(s3, bucketName, accountId);
    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