🌜
🌞
@middy/s3-key-normalizer

@middy/s3-key-normalizer

v2.5.7

S3 key normalizer middleware for the middy framework

npm install @middy/s3-key-normalizer

README

Middy s3-key-normalizer middleware

Middy logo

S3 key normalizer middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda

Normalizes key names in s3 events.

S3 events like S3 PUT and S3 DELETE will contain in the event a list of the files that were affected by the change.

In this list the file keys are encoded in a very peculiar way (urlencoded and space characters replaced by a +). Very often you will use the key directly to perform operations on the file using the AWS S3 SDK, in which case it's very easy to forget to decode the key correctly.

This middleware, once attached, makes sure that every S3 event has the file keys properly normalized.

Install

To install this middleware you can use NPM:

npm install --save @middy/s3-key-normalizer

Options

This middleware does not have any option

Sample usage

import middy from '@middy/core'
import s3KeyNormalizer from '@middy/s3-key-normalizer'

const handler = middy((event, context) => {
  // use the event key directly without decoding it
  console.log(event.Records[0].s3.object.key)

  // return all the keys
  return event.Records.map(record => record.s3.object.key)
})

handler
  .use(s3KeyNormalizer())

Middy documentation and examples

For more documentation and examples, refers to the main Middy monorepo on GitHub or Middy official website.

Contributing

Everyone is very welcome to contribute to this repository. Feel free to raise issues or to submit Pull Requests.

License

Licensed under MIT License. Copyright (c) 2017-2021 Luciano Mammino, will Farrell, and the Middy team.

FOSSA Status

Release Notes

2.5.7
By will Farrell • Published on January 25, 2022

Fix publishing transpiling error in 2.5.6. Thanks to @maximepichou and @rreubenreyes for reporting.

General

License
MIT
Typescript Types
Built-in
Tree-shakeable
No

Popularity

GitHub Stargazers
3,028
Community Interest
2,905
Number of Forks
293

Maintenance

Commits
10/219/220250
Last Commit
Open Issues
6
Closed Issues
407
Open Pull Requests
1
Closed Pull Requests
149

Versions

Versions Released
10/219/2203
Latest Version Released
Jan 25, 2022
Current Tags
latest2.5.7
next2.0.0-beta.0

Dependencies

Dependencies (0)
Dev Dependencies (2)

Contributors

willfarrell
willfarrell
Commits: 384
lmammino
lmammino
Commits: 113
vladgolubev
vladgolubev
Commits: 12
greenkeeper[bot]
greenkeeper[bot]
Commits: 12
thejuan
thejuan
Commits: 12
dkatavic
dkatavic
Commits: 11
gsingh1
gsingh1
Commits: 10
joseSantacruz
joseSantacruz
Commits: 9
leog
leog
Commits: 6
theburningmonk
theburningmonk
Commits: 6
ossareh
ossareh
Commits: 5
munierujp
munierujp
Commits: 4
JimiPedros
JimiPedros
Commits: 4
sdomagala
sdomagala
Commits: 4
chris-heathwood-uoy
chris-heathwood-uoy
Commits: 3