Skip to content

Commit

Permalink
feat(Slack Node): Move from Binary Buffer to Binary streaming (#5612)
Browse files Browse the repository at this point in the history
✨ Add Binary streaming instead of binary buffering
  • Loading branch information
agobrech authored Mar 3, 2023
1 parent e949db3 commit 9420b0f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/nodes-base/nodes/Slack/V2/SlackV2.node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable n8n-nodes-base/node-filename-against-convention */
import type { IExecuteFunctions } from 'n8n-core';
import { BINARY_ENCODING } from 'n8n-core';
import type { Readable } from 'stream';

import type {
IDataObject,
Expand Down Expand Up @@ -1072,18 +1073,21 @@ export class SlackV2 implements INodeType {
{ itemIndex: i },
);
}
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(
i,
binaryPropertyName,
);
let uploadData: Buffer | Readable;
const itemBinaryData = items[i].binary![binaryPropertyName];
if (itemBinaryData.id) {
uploadData = this.helpers.getBinaryStream(itemBinaryData.id);
} else {
uploadData = Buffer.from(itemBinaryData.data, BINARY_ENCODING);
}
body.file = {
//@ts-ignore
value: binaryDataBuffer,
value: uploadData,
options: {
//@ts-ignore
filename: items[i].binary[binaryPropertyName].fileName,
filename: itemBinaryData.fileName,
//@ts-ignore
contentType: items[i].binary[binaryPropertyName].mimeType,
contentType: itemBinaryData.mimeType,
},
};
responseData = await slackApiRequest.call(
Expand Down

0 comments on commit 9420b0f

Please sign in to comment.