Swapnil
Swapnil

Reputation: 864

Trigger AWS Lambda in Java for the newly uploaded file

I am working on a requirement where I want to trigger the AWS Lambda function written in Java when a file is uploaded on S3 bucket. The condition is that the function should pick-up the latest file in the bucket. Right now, I have the lambda function which picks up the specified file (having already specified file name). But as per the requirement, the file name can be anything(eg. web-log-). Is there any way to do that?

Since with lambda functions, we have access to the event object, can I use it to find out the recently uploaded file?

Upvotes: 1

Views: 1319

Answers (1)

Boris van Katwijk
Boris van Katwijk

Reputation: 3188

You could check out the AWS Lambda S3 tutorials, which should show how the uploaded object is passed in as event data. The example code contains a line which should point you in the right direction:

event.Records[0].s3.object.key

Upvotes: 2

Related Questions