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 { BINARY_ENCODING } from 'n8n-core';
import type { Readable } from 'stream';
import type {
IDataObject,
@ -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(