Trigger AWS Lambda in Java for the newly uploaded file











up vote
0
down vote

favorite












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?










share|improve this question


















  • 1




    Did you read docs.aws.amazon.com/lambda/latest/dg/with-s3.html ? Was anything specific unclear?
    – Boris van Katwijk
    Nov 12 at 7:56










  • @BorisvanKatwijk Yeah! I checked that. But I could not find any information to work on the recently uploaded file. The situation is like this- Suppose there is a S3 bucket and there are already 4-5 files uploaded. As soon as the 6th file is uploaded, I want to trigger the code.
    – Swapnil
    Nov 12 at 8:05















up vote
0
down vote

favorite












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?










share|improve this question


















  • 1




    Did you read docs.aws.amazon.com/lambda/latest/dg/with-s3.html ? Was anything specific unclear?
    – Boris van Katwijk
    Nov 12 at 7:56










  • @BorisvanKatwijk Yeah! I checked that. But I could not find any information to work on the recently uploaded file. The situation is like this- Suppose there is a S3 bucket and there are already 4-5 files uploaded. As soon as the 6th file is uploaded, I want to trigger the code.
    – Swapnil
    Nov 12 at 8:05













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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?










share|improve this question













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?







amazon-web-services amazon-s3 aws-lambda






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 at 7:48









Swapnil

467




467








  • 1




    Did you read docs.aws.amazon.com/lambda/latest/dg/with-s3.html ? Was anything specific unclear?
    – Boris van Katwijk
    Nov 12 at 7:56










  • @BorisvanKatwijk Yeah! I checked that. But I could not find any information to work on the recently uploaded file. The situation is like this- Suppose there is a S3 bucket and there are already 4-5 files uploaded. As soon as the 6th file is uploaded, I want to trigger the code.
    – Swapnil
    Nov 12 at 8:05














  • 1




    Did you read docs.aws.amazon.com/lambda/latest/dg/with-s3.html ? Was anything specific unclear?
    – Boris van Katwijk
    Nov 12 at 7:56










  • @BorisvanKatwijk Yeah! I checked that. But I could not find any information to work on the recently uploaded file. The situation is like this- Suppose there is a S3 bucket and there are already 4-5 files uploaded. As soon as the 6th file is uploaded, I want to trigger the code.
    – Swapnil
    Nov 12 at 8:05








1




1




Did you read docs.aws.amazon.com/lambda/latest/dg/with-s3.html ? Was anything specific unclear?
– Boris van Katwijk
Nov 12 at 7:56




Did you read docs.aws.amazon.com/lambda/latest/dg/with-s3.html ? Was anything specific unclear?
– Boris van Katwijk
Nov 12 at 7:56












@BorisvanKatwijk Yeah! I checked that. But I could not find any information to work on the recently uploaded file. The situation is like this- Suppose there is a S3 bucket and there are already 4-5 files uploaded. As soon as the 6th file is uploaded, I want to trigger the code.
– Swapnil
Nov 12 at 8:05




@BorisvanKatwijk Yeah! I checked that. But I could not find any information to work on the recently uploaded file. The situation is like this- Suppose there is a S3 bucket and there are already 4-5 files uploaded. As soon as the 6th file is uploaded, I want to trigger the code.
– Swapnil
Nov 12 at 8:05












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










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





share|improve this answer





















  • That is the perfect solution. String key = event.getRecords().get(0).getS3().getObject().getKey(); The key variable holds the name of the file which trigerred the event. Thanks for your suggestion!
    – Swapnil
    Nov 12 at 8:34













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257798%2ftrigger-aws-lambda-in-java-for-the-newly-uploaded-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










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





share|improve this answer





















  • That is the perfect solution. String key = event.getRecords().get(0).getS3().getObject().getKey(); The key variable holds the name of the file which trigerred the event. Thanks for your suggestion!
    – Swapnil
    Nov 12 at 8:34

















up vote
1
down vote



accepted










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





share|improve this answer





















  • That is the perfect solution. String key = event.getRecords().get(0).getS3().getObject().getKey(); The key variable holds the name of the file which trigerred the event. Thanks for your suggestion!
    – Swapnil
    Nov 12 at 8:34















up vote
1
down vote



accepted







up vote
1
down vote



accepted






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





share|improve this answer












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






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 at 8:11









Boris van Katwijk

8871821




8871821












  • That is the perfect solution. String key = event.getRecords().get(0).getS3().getObject().getKey(); The key variable holds the name of the file which trigerred the event. Thanks for your suggestion!
    – Swapnil
    Nov 12 at 8:34




















  • That is the perfect solution. String key = event.getRecords().get(0).getS3().getObject().getKey(); The key variable holds the name of the file which trigerred the event. Thanks for your suggestion!
    – Swapnil
    Nov 12 at 8:34


















That is the perfect solution. String key = event.getRecords().get(0).getS3().getObject().getKey(); The key variable holds the name of the file which trigerred the event. Thanks for your suggestion!
– Swapnil
Nov 12 at 8:34






That is the perfect solution. String key = event.getRecords().get(0).getS3().getObject().getKey(); The key variable holds the name of the file which trigerred the event. Thanks for your suggestion!
– Swapnil
Nov 12 at 8:34




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53257798%2ftrigger-aws-lambda-in-java-for-the-newly-uploaded-file%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine