Search in sources :

Example 51 with Region

use of software.amazon.awssdk.regions.Region 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)

Example 52 with Region

use of software.amazon.awssdk.regions.Region in project aws-doc-sdk-examples by awsdocs.

the class PutObjectMetadata method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "  <bucketName> <objectKey> <objectPath> \n\n" + "Where:\n" + "  bucketName - the Amazon S3 bucket to upload an object into.\n" + "  objectKey - the object to upload (for example, book.pdf).\n" + "  objectPath - the path where the file is located (for example, C:/AWS/book2.pdf). \n\n";
    if (args.length != 3) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    String objectKey = args[1];
    String objectPath = args[2];
    System.out.println("Putting object " + objectKey + " into bucket " + bucketName);
    System.out.println("  in bucket: " + bucketName);
    Region region = Region.US_EAST_1;
    S3Client s3 = S3Client.builder().region(region).build();
    String result = putS3Object(s3, bucketName, objectKey, objectPath);
    System.out.println("Tag information: " + result);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 53 with Region

use of software.amazon.awssdk.regions.Region in project aws-doc-sdk-examples by awsdocs.

the class RestoreObject method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    <bucketName> <keyName> <expectedBucketOwner>\n\n" + "Where:\n" + "    bucketName - the Amazon S3 bucket name. \n\n" + "    keyName - the key name of an object with a Storage class value of Glacier. \n\n" + "    expectedBucketOwner - the account that owns the bucket (you can obtain this value from the AWS Management Console). \n\n";
    if (args.length != 3) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    String keyName = args[1];
    String expectedBucketOwner = args[2];
    Region region = Region.US_WEST_2;
    S3Client s3 = S3Client.builder().region(region).build();
    restoreS3Object(s3, bucketName, keyName, expectedBucketOwner);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 54 with Region

use of software.amazon.awssdk.regions.Region in project aws-doc-sdk-examples by awsdocs.

the class S3Scenario method main.

public static void main(String[] args) throws IOException {
    final String usage = "\n" + "Usage:\n" + "    <bucketName> <key> <objectPath> <savePath> <toBucket>\n\n" + "Where:\n" + "    bucketName - the Amazon S3 bucket to create.\n\n" + "    key - the key to use.\n\n" + "    objectPath - the path where the file is located (for example, C:/AWS/book2.pdf). " + "    savePath - the path where the file is saved after it's downloaded (for example, C:/AWS/book2.pdf). " + "    toBucket - an Amazon S3 bucket to where an object is copied to (for example, C:/AWS/book2.pdf). ";
    if (args.length != 5) {
        System.out.println(usage);
        System.exit(1);
    }
    String bucketName = args[0];
    String key = args[1];
    String objectPath = args[2];
    String savePath = args[3];
    String toBucket = args[4];
    Region region = Region.US_EAST_1;
    S3Client s3 = S3Client.builder().region(region).build();
    // Create an Amazon S3 bucket.
    createBucket(s3, bucketName);
    // Update a local file to the Amazon S3 bucket.
    uploadLocalFile(s3, bucketName, key, objectPath);
    // Download the object to another local file.
    getObjectBytes(s3, bucketName, key, savePath);
    // Perform a multipart upload.
    String multipartKey = "multiPartKey";
    multipartUpload(s3, toBucket, multipartKey);
    // List all objects located in the Amazon S3 bucket.
    // Show 2 ways
    listAllObjects(s3, bucketName);
    anotherListExample(s3, bucketName);
    // Copy the object to another Amazon S3 bucket
    copyBucketObject(s3, bucketName, key, toBucket);
    // Delete the object from the Amazon S3 bucket.
    deleteObjectFromBucket(s3, bucketName, key);
    // Delete the Amazon S3 bucket
    deleteBucket(s3, bucketName);
    System.out.println("All Amazon S3 operations were successfully performed");
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Example 55 with Region

use of software.amazon.awssdk.regions.Region in project aws-doc-sdk-examples by awsdocs.

the class SetWebsiteConfiguration method main.

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage: " + "   <bucketName> [indexdoc] \n\n" + "Where:\n" + "   bucketName   - the Amazon S3 bucket to set the website configuration on. \n" + "   indexdoc - The index document, ex. 'index.html'\n" + "              If not specified, 'index.html' will be set.\n";
    if (args.length < 2) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String bucketName = args[0];
    String indexDoc = "index.html";
    Region region = Region.US_EAST_1;
    S3Client s3 = S3Client.builder().region(region).build();
    setWebsiteConfig(s3, bucketName, indexDoc);
    s3.close();
}
Also used : Region(software.amazon.awssdk.regions.Region) S3Client(software.amazon.awssdk.services.s3.S3Client)

Aggregations

Region (software.amazon.awssdk.regions.Region)534 S3Client (software.amazon.awssdk.services.s3.S3Client)43 RekognitionClient (software.amazon.awssdk.services.rekognition.RekognitionClient)32 DynamoDbClient (software.amazon.awssdk.services.dynamodb.DynamoDbClient)31 IamClient (software.amazon.awssdk.services.iam.IamClient)23 PersonalizeClient (software.amazon.awssdk.services.personalize.PersonalizeClient)22 Ec2Client (software.amazon.awssdk.services.ec2.Ec2Client)20 Test (org.junit.Test)17 AwsCredentialsProvider (software.amazon.awssdk.auth.credentials.AwsCredentialsProvider)15 KmsClient (software.amazon.awssdk.services.kms.KmsClient)15 URI (java.net.URI)13 CodeCommitClient (software.amazon.awssdk.services.codecommit.CodeCommitClient)13 GlueClient (software.amazon.awssdk.services.glue.GlueClient)12 Properties (java.util.Properties)11 DynamoDbEnhancedClient (software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient)11 SesClient (software.amazon.awssdk.services.ses.SesClient)11 SdkBytes (software.amazon.awssdk.core.SdkBytes)9 Route53Client (software.amazon.awssdk.services.route53.Route53Client)9 CloudTrailClient (software.amazon.awssdk.services.cloudtrail.CloudTrailClient)8 CloudWatchClient (software.amazon.awssdk.services.cloudwatch.CloudWatchClient)8