Skip to content

S3 object keys are not Url decoded in S3Events received Lambda via S3Notification #1182

@ElectricVampire

Description

@ElectricVampire

Describe the bug

If I upload an Object in S3 bucket where file name has space in it. Eg. "NEW FILE.txt", The object URL becomes - https://myBucket/NEW+FILE.txt which is correct.

Now When I received an event in my lambda via S3Notification. Property -> S3.Object.Key has "NEW+FILE.txt"

Key value should be Url decoded as the real key of this object is "NEW FILE.txt".

Expected Behavior

Key value of object should be "NEW FILE.txt".

Current Behavior

Key value of object should be "NEW+FILE.txt".

Reproduction Steps

  • Create a bucket
  • Create a lambda
  • Add a S3 trigger in lambda
  • Upload a object named "NEW FILE.txt" in S3 bucket
  • Verify that key name in bucket is "NEW FILE.txt"
  • Once you uploaded the object, event will be triggered and will execute lambda
  • Check S3.Object.Key property of S3Event object. It shows key value as "NEW+FILE.txt" while it should be "NEW FILE.txt"

Possible Solution

I think while serialization of S3Event, we can just do WebUtility.UrlDecode(key) which will santize the key from encoded chars which were added during url creation.

Additional Information/Context

We all know that having space is filename is not ideal but we depend on our upstream for this filename and they just can't change it.

AWS .NET SDK and/or Package version used

AWSSDK.S3 3.7.9.2

Targeted .NET Platform

.NET CORE 3.1

Operating System and version

AmazonLinux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions