Skip to content

Commit a2d0761

Browse files
committed
Refactoring
1 parent 9b56173 commit a2d0761

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

awslambdas3event/pom.xml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,15 @@
1616
</properties>
1717

1818
<dependencies>
19-
<dependency>
20-
<groupId>com.amazonaws</groupId>
21-
<artifactId>aws-java-sdk-s3</artifactId>
22-
<version>1.11.265</version>
23-
</dependency>
24-
<dependency>
25-
<groupId>com.amazonaws</groupId>
26-
<artifactId>aws-java-sdk-lambda</artifactId>
27-
<version>1.11.265</version>
28-
</dependency>
2919
<dependency>
3020
<groupId>com.amazonaws</groupId>
3121
<artifactId>aws-lambda-java-core</artifactId>
32-
<version>1.1.0</version>
22+
<version>1.2.1</version>
3323
</dependency>
3424
<dependency>
3525
<groupId>com.amazonaws</groupId>
3626
<artifactId>aws-lambda-java-events</artifactId>
37-
<version>1.3.0</version>
27+
<version>3.7.0</version>
3828
</dependency>
3929
</dependencies>
4030

@@ -43,7 +33,7 @@
4333
<plugin>
4434
<groupId>org.apache.maven.plugins</groupId>
4535
<artifactId>maven-compiler-plugin</artifactId>
46-
<version>3.7.0</version>
36+
<version>3.8.1</version>
4737
<configuration>
4838
<source>${jdk.version}</source>
4939
<target>${jdk.version}</target>
@@ -52,7 +42,7 @@
5242
<plugin>
5343
<groupId>org.apache.maven.plugins</groupId>
5444
<artifactId>maven-shade-plugin</artifactId>
55-
<version>3.0.0</version>
45+
<version>3.2.4</version>
5646
<configuration>
5747
<createDependencyReducedPom>false</createDependencyReducedPom>
5848
</configuration>

awslambdas3event/src/main/java/example/S3EventHandler.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,28 @@
33
* It handles an AWS simple Lambda function that sends information to the log
44
* about an object when it appears in a S3 bucket.
55
*/
6-
6+
77
package example;
88

99
import com.amazonaws.services.lambda.runtime.Context;
1010
import com.amazonaws.services.lambda.runtime.RequestHandler;
11-
import com.amazonaws.services.s3.event.S3EventNotification.S3EventNotificationRecord;
11+
import com.amazonaws.services.lambda.runtime.events.S3Event;
12+
import com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification.S3EventNotificationRecord;
1213

13-
public class S3CreationEvent implements RequestHandler<com.amazonaws.services.lambda.runtime.events.S3Event, String> {
14+
public class S3EventHandler implements RequestHandler<S3Event, String> {
1415

15-
public String handleRequest(com.amazonaws.services.lambda.runtime.events.S3Event input, Context context) {
16+
@Override
17+
public String handleRequest(S3Event s3Event, Context context) {
1618
// Get Event Record
17-
S3EventNotificationRecord record = input.getRecords().get(0);
19+
S3EventNotificationRecord record = s3Event.getRecords().get(0);
1820

1921
// Source Bucket Name
2022
String srcBucketName = record.getS3().getBucket().getName();
2123

2224
// Source File Name
23-
String srcObjectName = record.getS3().getObject().getKey(); // Name doesn't contain any special characters
25+
String srcObjectName = record.getS3().getObject().getUrlDecodedKey();
2426

25-
context.getLogger().log("Input: " + input + "\n");
27+
context.getLogger().log("S3Event: " + s3Event + "\n");
2628
context.getLogger().log("Bucket: " + srcBucketName + "\n");
2729
context.getLogger().log("Object: " + srcObjectName + "\n");
2830

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Manifest-Version: 1.0
2+
Main-Class: example.S3EventHandler

0 commit comments

Comments
 (0)