Skip to content

Commit

Permalink
fix: headers[headerName].trim is not a function
Browse files Browse the repository at this point in the history
fixes: #1097
  • Loading branch information
willfarrell committed Sep 17, 2023
1 parent 50d8e89 commit 24a6ff2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 2 additions & 7 deletions packages/s3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ const s3Middleware = (opts = {}) => {
for (const internalKey of Object.keys(options.fetchData)) {
if (cachedValues[internalKey]) continue
values[internalKey] = client
.send(
new GetObjectCommand({
...options.fetchData[internalKey],
ChecksumMode: true
})
)
.send(new GetObjectCommand(options.fetchData[internalKey]))
.then(async (resp) => {
let value = await resp.Body.transformToString()
if (contentTypePattern.test(resp.headers.ContentType)) {
if (contentTypePattern.test(resp.ContentType)) {
value = jsonSafeParse(value)
}
return value
Expand Down
6 changes: 4 additions & 2 deletions website/docs/middlewares/s3.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ NOTES:

```javascript
import middy from '@middy/core'
import appConfig from '@middy/s3'
import s3 from '@middy/s3'

const handler = middy((event, context) => {
console.log(context.config)
const response = {
statusCode: 200,
headers: {},
Expand All @@ -53,7 +54,8 @@ handler.use(
Bucket: '...',
Key: '...'
}
}
},
setToContext: true
})
)
```
Expand Down

0 comments on commit 24a6ff2

Please sign in to comment.