Skip to content

Commit b134a7b

Browse files
authored
fix bug (#73)
* Fixed bug in `Get New and Updated S3 Objects` trigger when selected Emit Behaviour - Fetch All
1 parent 40090fe commit b134a7b

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.5.1 (May 20, 2022)
2+
* Fixed bug in `Get New and Updated S3 Objects` trigger when selected Emit Behaviour - Fetch All
3+
14
# 1.5.0 (May 20, 2022)
25
* Created new `Read file` action instead of existing due to incorrect output metadata, old one set as deprecated
36
* Fix memory leak for `Read file` action and `Get New and Updated S3 Objects` trigger, also added attachment url in message body to them

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ The component is based on [AWS S3 SDK](https://aws.amazon.com/sdk-for-node-js/ '
4646
#### Environment variables
4747
Name|Mandatory|Description|Values|
4848
|----|---------|-----------|------|
49-
|`LOG_LEVEL`| false | Controls logger level | `trace`, `debug`, `info`, `warning`, `error` |
5049
|`ATTACHMENT_MAX_SIZE`| false | For `elastic.io` attachments configuration. Maximal possible attachment size in bytes. By default set to `104857600` and according to platform limitations **CAN'T** be bigger than that. | Up to `104857600` bytes (100MB)|
5150
|`ACCESS_KEY_ID`| false | For integration-tests is required to specify this variable | |
5251
|`ACCESS_KEY_SECRET`| false | For integration-tests is required to specify this variable | |

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"title": "AWS S3",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"description": "Integration component that can read and write to AWS S3",
55
"docsUrl": "https://github.com/elasticio/amazon-s3-component",
66
"credentials": {

lib/utils/pollingUtil.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ class AwsS3Polling extends PollingTrigger {
3131
for (let i = 0; i < files.length; i += 1) {
3232
const file = files[i];
3333
this.logger.info('Processing file with size: %d', file.Size);
34-
if (file.Size > params.ATTACHMENT_MAX_SIZE) {
35-
const err = `File "${file.Key}" with size ${file.Size} bytes is too big for attachment usage. `
36-
+ `Current attachment max size is ${params.ATTACHMENT_MAX_SIZE} bytes`;
37-
this.logger.error(err);
38-
throw new Error(err);
39-
}
4034
const resultMessage = messages.newMessageWithBody(file);
4135

4236
if (this.cfg.enableFileAttachments) {
37+
if (file.Size > params.ATTACHMENT_MAX_SIZE) {
38+
const err = `File "${file.Key}" with size ${file.Size} bytes is too big for attachment usage. `
39+
+ `Current ATTACHMENT_MAX_SIZE is ${params.ATTACHMENT_MAX_SIZE} bytes`;
40+
this.logger.error(err);
41+
throw new Error(err);
42+
}
4343
await this.s3FileToAttachment(resultMessage, path.basename(file.Key), file.Size);
4444
resultMessage.body.attachmentUrl = resultMessage.attachments[path.basename(file.Key)].url;
4545
}
@@ -61,14 +61,14 @@ class AwsS3Polling extends PollingTrigger {
6161
for (let i = 0; i < results.length; i += 1) {
6262
if (results[i].Size > params.ATTACHMENT_MAX_SIZE) {
6363
const err = `File "${results[i].Key}" with size ${results[i].Size} bytes is too big for attachment usage. `
64-
+ `Current attachment max size is ${params.ATTACHMENT_MAX_SIZE} bytes`;
64+
+ `Current ATTACHMENT_MAX_SIZE is ${params.ATTACHMENT_MAX_SIZE} bytes`;
6565
this.logger.error(err);
6666
throw new Error(err);
6767
}
6868
const dummyMessage = messages.newEmptyMessage();
6969
await this.s3FileToAttachment(dummyMessage, path.basename(results[i].Key), results[i].Size);
7070
attachments[results[i].Key] = dummyMessage.attachments[results[i].Key];
71-
resultMessage.results[i].attachmentUrl = dummyMessage.attachments[results[i].Key].url;
71+
resultMessage.body.results[i].attachmentUrl = dummyMessage.attachments[path.basename(results[i].Key)].url;
7272
}
7373

7474
resultMessage.attachments = attachments;

0 commit comments

Comments
 (0)