Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20
v22
13 changes: 12 additions & 1 deletion lib/functions/rloi-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ module.exports.handler = async (event) => {
const bucket = event.Records[0].s3.bucket.name
const key = event.Records[0].s3.object.key
const data = await s3.getObject({ Bucket: bucket, Key: key })
const bodyContents = await data.Body.transformToString()
let bodyContents = ''
if (data.Body && typeof data.Body.transformToString === 'function') {
// Test mock or AWS SDK v3 convenience method
bodyContents = await data.Body.transformToString()
} else if (data.Body && typeof data.Body[Symbol.asyncIterator] === 'function') {
// Node.js stream (production)
for await (const chunk of data.Body) {
bodyContents += chunk
}
} else {
throw new Error('data.Body is not async iterable and has no transformToString method')
}
const file = await util.parseXml(bodyContents)

// use pool and not client due to multiple database queries
Expand Down
Loading