feat(Slack Node): Move from Binary Buffer to Binary streaming (#5612)

 Add Binary streaming instead of binary buffering
This commit is contained in:
agobrech 2023-03-03 18:11:27 +01:00 committed by GitHub
parent e949db3525
commit 9420b0fdf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,6 @@
/* eslint-disable n8n-nodes-base/node-filename-against-convention */
import type { IExecuteFunctions } from 'n8n-core'; import type { IExecuteFunctions } from 'n8n-core';
import { BINARY_ENCODING } from 'n8n-core';
import type { Readable } from 'stream';
import type { import type {
IDataObject, IDataObject,
@ -1072,18 +1073,21 @@ export class SlackV2 implements INodeType {
{ itemIndex: i }, { itemIndex: i },
); );
} }
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( let uploadData: Buffer | Readable;
i, const itemBinaryData = items[i].binary![binaryPropertyName];
binaryPropertyName, if (itemBinaryData.id) {
); uploadData = this.helpers.getBinaryStream(itemBinaryData.id);
} else {
uploadData = Buffer.from(itemBinaryData.data, BINARY_ENCODING);
}
body.file = { body.file = {
//@ts-ignore //@ts-ignore
value: binaryDataBuffer, value: uploadData,
options: { options: {
//@ts-ignore //@ts-ignore
filename: items[i].binary[binaryPropertyName].fileName, filename: itemBinaryData.fileName,
//@ts-ignore //@ts-ignore
contentType: items[i].binary[binaryPropertyName].mimeType, contentType: itemBinaryData.mimeType,
}, },
}; };
responseData = await slackApiRequest.call( responseData = await slackApiRequest.call(