Skip to content

Commit

Permalink
Merge pull request #1558 from gtmjohnson/fix-s3-lambda-dotnet
Browse files Browse the repository at this point in the history
Fix s3 lambda dotnet
  • Loading branch information
jbesw authored Aug 8, 2023
2 parents 136db8d + c72cf35 commit 7c5ee0c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions s3-lambda-dotnet/ImageResize/Function.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace ImageResize;
public class Function
{
IAmazonS3 S3Client { get; set; }


/// <summary>
/// Default constructor. This constructor is used by Lambda to construct the instance. When invoked in a Lambda environment
Expand All @@ -39,7 +40,7 @@ public Function(IAmazonS3 s3Client)

public async Task<string> FunctionHandler(S3Event evnt, ILambdaContext context)
{
string[] fileExtentions = new string[] { ".jpg", ".jpeg" };
string[] fileExtensions = new string[] { ".jpg", ".jpeg" };
var s3Event = evnt.Records?[0].S3;
if (s3Event == null)
{
Expand All @@ -51,7 +52,7 @@ public async Task<string> FunctionHandler(S3Event evnt, ILambdaContext context)
foreach (var record in evnt.Records)
{
LambdaLogger.Log("----> File: " + record.S3.Object.Key);
if (!fileExtentions.Contains(Path.GetExtension(record.S3.Object.Key).ToLower()))
if (!fileExtensions.Contains(Path.GetExtension(record.S3.Object.Key).ToLower()))
{
LambdaLogger.Log("File Extension is not supported - " + s3Event.Object.Key);
continue;
Expand Down
4 changes: 3 additions & 1 deletion s3-lambda-dotnet/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ Resources:
Properties:
Bucket: !Ref SourceBucket
Events: s3:ObjectCreated:*
Filter:
Filter:
S3Key:
Rules:
- Name: prefix
Value: 'images/'
- Name: suffix
Value: '.jpeg'
Policies:
Expand Down

0 comments on commit 7c5ee0c

Please sign in to comment.