Search in sources :

Example 21 with S3Client

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

the class GetObjectTags 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();
    listTags(s3, bucketName, keyName);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 22 with S3Client

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

the class KMSEncryptionExample method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <objectName> <bucketName> <objectPath> <outPath> <keyId>\n\n" + "Where:\n" + "    objectName - the name of the object. \n\n" + "    bucketName - the Amazon S3 bucket name that contains the object (for example, bucket1). \n" + "    objectPath - the path to a TXT file to encrypt and place into a Amazon S3 bucket (for example, C:/AWS/test.txt).\n" + "    outPath - the path where a text file is written to after it's decrypted (for example, C:/AWS/testPlain.txt).\n" + "    keyId - the id of the AWS KMS key to use to encrpt/decrypt the data. You can obtain the key ID value from the AWS Management Console.\n";
    if (args.length != 5) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String objectName = args[0];
    String bucketName = args[1];
    String objectPath = args[2];
    String outPath = args[3];
    String keyId = args[4];
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();
    putEncryptData(s3, objectName, bucketName, objectPath, keyId);
    getEncryptedData(s3, bucketName, objectName, outPath, keyId);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 23 with S3Client

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

the class ListMultipartUploads method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <bucketName> \n\n" + "Where:\n" + "    bucketName - the name of the Amazon S3 bucket where an in-progress multipart upload is occurring.\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();
    listUploads(s3, bucketName);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 24 with S3Client

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

the class S3Service method getClient.

private S3Client getClient() {
    Region region = Region.US_EAST_1;
    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 25 with S3Client

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

the class ExportEndpoints method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "This program performs the following steps:\n\n" + "1) Exports the endpoints to an Amazon S3 bucket.\n" + "2) Downloads the exported endpoints files from Amazon S3.\n" + "3) Parses the endpoints files to obtain the endpoint IDs and prints them.\n" + "Usage: ExportEndpoints <applicationId> <s3BucketName> <iamExportRoleArn> <path>\n\n" + "Where:\n" + "  applicationId - The ID of the Amazon Pinpoint application that has the endpoint.\n" + "  s3BucketName - The name of the Amazon S3 bucket to export the JSON file to. \n" + "  iamExportRoleArn - The ARN of an IAM role that grants Amazon Pinpoint write permissions to the S3 bucket." + "  path - The path where the files downloaded from the Amazon S3 bucket are written (for example, C:/AWS/).\n";
    if (args.length != 4) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String applicationId = args[0];
    String s3BucketName = args[1];
    String iamExportRoleArn = args[2];
    String path = args[3];
    System.out.println("Deleting an application with ID: " + applicationId);
    Region region = Region.US_EAST_1;
    PinpointClient pinpoint = PinpointClient.builder().region(region).build();
    S3Client s3Client = S3Client.builder().region(region).build();
    exportAllEndpoints(pinpoint, s3Client, applicationId, s3BucketName, path, iamExportRoleArn);
    pinpoint.close();
    s3Client.close();
}
Also used : PinpointClient(software.amazon.awssdk.services.pinpoint.PinpointClient) 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