What are the best practices to upload file to S3 and also trigger a lambda

0 votes

I would like to implement the following scenario using AWS S3 and Lambda.

User takes a photo from mobile, add description, location and more attributes as a separate metadata. Upload the image file to S3 with the metadata as the file inner metadata. According to that link I can do it by adding a key value pair to ObjectMetadata with "x-amz-meta-" as a key.

I was managed to invoke the lambda every creation of a file in my S3 bucket but in the S3Event from the Lambda's invocation method I'm not getting the metadata that I putted in the ObjectMetadata.

Code sample for the upload process:

PutObjectRequest por = new PutObjectRequest(BUCKET_NAME, KEY_NAME, file);
ObjectMetadata metadata = new ObjectMetadata();
metadata.addUserMetadata("x-amz-meta-xxxxx", "test123");
por.setMetadata(metadata);
s3client.putObject(por);

I hope that I provided enough information

Sep 28, 2018 in AWS by bug_seeker
• 15,520 points
3,291 views

1 answer to this question.

0 votes

AWS recommends to store files on S3, files' metadata on the DynamoDB. With this approach easy and cost effective to perform a search by the metadata. Please keep in mind, that according to S3 pricing model you pay for each API call.

answered Sep 28, 2018 by Priyaj
• 58,090 points

Related Questions In AWS

0 votes
1 answer

Unziiping a tar.gz file in aws s3 bucket and upload it back to s3 using lambda

Hi@khyati, You can do your task using lambda. ...READ MORE

answered Dec 3, 2020 in AWS by MD
• 95,440 points
17,889 views
0 votes
1 answer

What are the best practices for security in Lambda?

For security, there are some of the ...READ MORE

answered Jan 11, 2019 in AWS by Diksha
383 views
0 votes
1 answer

how to access AWS S3 from Lambda in VPC

With boto3, the S3 urls are virtual by default, ...READ MORE

answered Sep 28, 2018 in AWS by Priyaj
• 58,090 points
9,601 views
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to upload a file from S3 in Lambda?

Yes there is an option where you ...READ MORE

answered Jan 24, 2019 in AWS by Priyaj
• 58,090 points
4,818 views
0 votes
1 answer

How to upload to Dropbox and overwrite a file Using CURL

You need to use mode with parameter ...READ MORE

answered Aug 8, 2018 in AWS by Priyaj
• 58,090 points
4,515 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP