Skip to content

Commit

Permalink
java - adding description for s3 examples
Browse files Browse the repository at this point in the history
  • Loading branch information
soo-aws committed Oct 18, 2018
1 parent 355e6e9 commit d23bf6b
Show file tree
Hide file tree
Showing 22 changed files with 57 additions and 113 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[CopyObject.java demonstrates how to copy an object from one bucket to another.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[copyObject]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[CreateBucket.java demonstrates how to create a new S3 bucket.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[createBucket]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down Expand Up @@ -90,4 +88,3 @@ public static void main(String[] args)
}
}
}

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[DeleteBucket.java demonstrates how to delete an existing bucket.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[deleteObject]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down Expand Up @@ -109,4 +107,3 @@ public static void main(String[] args)
System.out.println("Done!");
}
}

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[DeleteBucketPolicy.java demonstrates how to delete a bucket policy on an existing S3 bucket.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[deleteBucketPolicy]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down Expand Up @@ -67,5 +65,3 @@ public static void main(String[] args)
System.out.println("Done!");
}
}


Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[DeleteObject.java demonstrates how to delete an existing object.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[deleteObject]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down Expand Up @@ -65,4 +63,3 @@ public static void main(String[] args)
System.out.println("Done!");
}
}

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[DeleteObjects.java demonstrates how to delete multiple objects in an S3 bucket.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[deleteObjects]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down Expand Up @@ -72,4 +70,3 @@ public static void main(String[] args)
System.out.println("Done!");
}
}

Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[DeleteWebsiteConfiguration.java demonstrates how to delete the website configuration for an S3 bucket set up as a static website.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down Expand Up @@ -68,4 +65,3 @@ public static void main(String[] args)
System.out.println("Done!");
}
}

10 changes: 4 additions & 6 deletions java/example_code/s3/src/main/java/aws/example/s3/GetAcl.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[GetAcl.java demonstrates how to get the access control list (ACL) of an S3 bucket and an object.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[getBucketAcl]
//snippet-keyword:[getObjectAcl]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand All @@ -32,7 +31,7 @@
import java.util.List;

/**
* Add a bucket policy to an existing S3 bucket.
* Retrieve the access control list of an existing S3 bucket.
*
* This code expects that you have AWS credentials set up per:
* http://docs.aws.amazon.com/java-sdk/latest/developer-guide/setup-credentials.html
Expand Down Expand Up @@ -107,4 +106,3 @@ public static void main(String[] args)
System.out.println("Done!");
}
}

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[GetBucketPolicy.java demonstrates how to get the bucket policy from an existing S3 bucket.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[getBucketPolicy]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down Expand Up @@ -78,4 +76,3 @@ public static void main(String[] args)
System.out.println("Done!");
}
}

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[GetObject.java demonstrates how to get an object within an Amazon S3 bucket.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[getObject]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down Expand Up @@ -83,4 +81,3 @@ public static void main(String[] args)
System.out.println("Done!");
}
}

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[GetWebsiteConfiguration.java demonstrates how to get the website configuration for an S3 bucket.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[getBucketWebsiteConfiguration]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down Expand Up @@ -77,4 +75,3 @@ public static void main(String[] args)
getWebsiteConfig(bucket_name);
}
}

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[ListBuckets.java demonstrates how to get a list of buckets in your AWS account.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[listBuckets]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[ListObjects.java demonstrates how to list objects within an Amazon S3 bucket.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[listObjectsV2]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[PutObject.java demonstrates how to upload a file to an Amazon S3 bucket.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[putObject]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down Expand Up @@ -65,4 +63,3 @@ public static void main(String[] args)
System.out.println("Done!");
}
}

19 changes: 8 additions & 11 deletions java/example_code/s3/src/main/java/aws/example/s3/S3Encrypt.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[S3Encrypt.java demonstrates how to use various encryption settings in Amazon S3.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[AmazonS3Encryption]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down Expand Up @@ -48,27 +46,27 @@
* This code expects that you have AWS credentials set up per:
* http://docs.aws.amazon.com/java-sdk/latest/developer-guide/setup-credentials.html
* This code also requires you to install the Unlimited Strength Java(TM) Cryptography Extension Policy Files (JCE)
* You can install this from the oracle site: http://www.oracle.com
* You can install this from the oracle site: http://www.oracle.com
*/
public class S3Encrypt
{
public static final String BUCKET_NAME = "s3EncryptTestBucket"; //add your bucket name
public static final String ENCRYPTED_KEY = "enc-key";
public static final String NON_ENCRYPTED_KEY = "some-key";

public static void main(String[] args)
{
System.out.println("calling encryption with customer managed keys");
S3Encrypt encrypt = new S3Encrypt();

try {
//can change to call the other encryption methods
encrypt.authenticatedEncryption_CustomerManagedKey();
encrypt.authenticatedEncryption_CustomerManagedKey();
} catch (NoSuchAlgorithmException ex) {
System.out.println(ex.getMessage());
}
}

/**
* Uses AES/GCM with AESWrap key wrapping to encrypt the key. Uses v2 metadata schema. Note that authenticated
* encryption requires the bouncy castle provider to be on the classpath. Also, for authenticated encryption the size
Expand All @@ -82,7 +80,7 @@ public void authenticatedEncryption_CustomerManagedKey() throws NoSuchAlgorithmE
.withCryptoConfiguration(new CryptoConfiguration(CryptoMode.AuthenticatedEncryption))
.withEncryptionMaterials(new StaticEncryptionMaterialsProvider(new EncryptionMaterials(secretKey)))
.build();

AmazonS3 s3NonEncrypt = AmazonS3ClientBuilder.defaultClient();

s3Encryption.putObject(BUCKET_NAME, ENCRYPTED_KEY, "some contents");
Expand Down Expand Up @@ -307,4 +305,3 @@ public void strictAuthenticatedEncryption_KmsManagedKey() throws NoSuchAlgorithm
}
}
}

8 changes: 3 additions & 5 deletions java/example_code/s3/src/main/java/aws/example/s3/SetAcl.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

//snippet-sourcedescription:[<<FILENAME>> demonstrates how to ...]
//snippet-sourcedescription:[SetAcl.java demonstrates how to add an access policy to an existing S3 bucket or object.]
//snippet-keyword:[Java]
//snippet-keyword:[Code Sample]
//snippet-keyword:[Amazon S3]
//snippet-keyword:[setBucketAcl]
//snippet-keyword:[setObjectAcl]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[AWS]


/*
Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Expand Down Expand Up @@ -117,4 +116,3 @@ public static void main(String[] args)
System.out.println("Done!");
}
}

Loading

0 comments on commit d23bf6b

Please sign in to comment.