-
Notifications
You must be signed in to change notification settings - Fork 682
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f24a9b6
commit 1b46a8c
Showing
5 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.shipmentEvents.util; | ||
|
||
import com.amazonaws.services.s3.AmazonS3; | ||
|
||
public class S3Events { | ||
|
||
AmazonS3 s3Client = S3ClientUtil.getS3Client(); | ||
|
||
//Create method to upload file to S3 | ||
public void uploadFile(String bucketName, String key, String filePath) { | ||
s3Client.putObject(bucketName, key, filePath); | ||
} | ||
|
||
//Create method to delete a file in S3 | ||
public void deleteFile(String bucketName, String key) { | ||
s3Client.deleteObject(bucketName, key); | ||
} | ||
|
||
//Create a method to list all files in a bucket | ||
public void listFiles(String bucketName) { | ||
s3Client.listObjects(bucketName); | ||
} | ||
|
||
//create method to iterate accross all the different s3 objects | ||
public void iterateS3Objects() { | ||
s3Client.listBuckets().forEach(bucket -> { | ||
bucket.getName(); | ||
bucket.getCreationDate(); | ||
bucket.getOwner(); | ||
bucket.getOwner().getDisplayName(); | ||
} | ||
); | ||
} | ||
} |