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,350 points
345 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
• 56,900 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer

What are the practical differences between AWS EFS, EBS and S3?

EFS  It is a file storage connected with ...READ MORE

answered Aug 7, 2018 in AWS by sunshine
• 1,240 points
169 views
0 votes
1 answer

How to upload a file to Amazon S3 without passing it my server?

This article pretty much explains the entire ...READ MORE

answered Aug 14, 2018 in AWS by Archana
• 4,090 points
82 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
• 56,900 points
1,922 views
0 votes
2 answers
0 votes
1 answer
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
• 56,900 points
726 views