diff --git a/src/main/java/Credentials.java b/src/main/java/Credentials.java index 1db3e26..001db86 100644 --- a/src/main/java/Credentials.java +++ b/src/main/java/Credentials.java @@ -6,7 +6,7 @@ public class Credentials { public static final String access_key_id= "AKIAJQBA6TTUVSE7ROHA"; - public static final String secret_access_key ="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"; + public static final String secret_access_key ="<>"; diff --git a/src/main/java/S3JavaSDKExample.java b/src/main/java/S3JavaSDKExample.java index 1369556..97178c0 100755 --- a/src/main/java/S3JavaSDKExample.java +++ b/src/main/java/S3JavaSDKExample.java @@ -18,8 +18,10 @@ public class S3JavaSDKExample { public static void main(String[] args)throws Exception { - demoServerSideEncryptionNotResource(); + System.out.print("boom"); + //demoServerSideEncryptionNotResource(); + createAndPopulateSimpleBucket(); } @@ -31,16 +33,20 @@ public static void createAndPopulateSimpleBucket() throws Exception { AmazonS3Client s3Client = new AmazonS3Client(awsCreds); - BucketUtils.deleteAllBuckets(s3Client); + // BucketUtils.deleteAllBuckets(s3Client); + + + String newBucketName = "matt" + System.currentTimeMillis(); - String newBucketName = "mattua" + System.currentTimeMillis(); s3Client.createBucket(newBucketName); final String fileName = "sometext.txt"; File file = new File(S3JavaSDKExample.class.getResource(fileName).toURI()); + + /* remember this is a new bucket and "folders" dont exist in S3, they are logical entities derived from the path specified in the key. S3 is just a key value store. @@ -56,7 +62,7 @@ public static void createAndPopulateSimpleBucket() throws Exception { { - PutObjectRequest putRequest1 = new PutObjectRequest(newBucketName, "unencrypted/" + fileName + "." + System.currentTimeMillis(), file); + PutObjectRequest putRequest1 = new PutObjectRequest(newBucketName, fileName + "." + System.currentTimeMillis(), file); PutObjectResult response1 = s3Client.putObject(putRequest1); System.out.println("Uploaded object encryption status is " + response1.getSSEAlgorithm()); @@ -156,7 +162,7 @@ public static void demoServerSideEncryptionNotResource() throws Exception { BucketUtils.deleteAllBuckets(s3Client); - String newBucketName = "mattua" + System.currentTimeMillis(); + String newBucketName = "matt" + System.currentTimeMillis(); s3Client.createBucket(newBucketName); String policy = BucketUtils.readFileFromResources("encrypted-folder-policy-notresource.txt").replace("bucketname",newBucketName);