mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
feat(Jira Software Node): Support binary streaming for very large binary files (#5589)
Move from buffer to binary streaming
This commit is contained in:
parent
f3c943ef81
commit
f61d779667
|
@ -1,6 +1,8 @@
|
|||
import type { Readable } from 'stream';
|
||||
import mergeWith from 'lodash.mergewith';
|
||||
|
||||
import type { IExecuteFunctions } from 'n8n-core';
|
||||
import { BINARY_ENCODING } from 'n8n-core';
|
||||
|
||||
import type {
|
||||
IBinaryKeyData,
|
||||
|
@ -1061,12 +1063,9 @@ export class Jira implements INodeType {
|
|||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
|
||||
let uploadData: Buffer | Readable;
|
||||
const item = items[i].binary as IBinaryKeyData;
|
||||
|
||||
const binaryData = item[binaryPropertyName];
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
||||
|
||||
if (binaryData === undefined) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
|
@ -1075,6 +1074,12 @@ export class Jira implements INodeType {
|
|||
);
|
||||
}
|
||||
|
||||
if (binaryData.id) {
|
||||
uploadData = this.helpers.getBinaryStream(binaryData.id);
|
||||
} else {
|
||||
uploadData = Buffer.from(binaryData.data, BINARY_ENCODING);
|
||||
}
|
||||
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/${apiVersion}/issue/${issueKey}/attachments`,
|
||||
|
@ -1085,7 +1090,7 @@ export class Jira implements INodeType {
|
|||
{
|
||||
formData: {
|
||||
file: {
|
||||
value: binaryDataBuffer,
|
||||
value: uploadData,
|
||||
options: {
|
||||
filename: binaryData.fileName,
|
||||
},
|
||||
|
@ -1154,7 +1159,7 @@ export class Jira implements INodeType {
|
|||
{},
|
||||
{},
|
||||
attachment?.json.content as string,
|
||||
{ json: false, encoding: null },
|
||||
{ json: false, encoding: null, useStream: true },
|
||||
);
|
||||
|
||||
(returnData[index].binary as IBinaryKeyData)[binaryPropertyName] =
|
||||
|
@ -1205,7 +1210,7 @@ export class Jira implements INodeType {
|
|||
{},
|
||||
{},
|
||||
attachment.json.content as string,
|
||||
{ json: false, encoding: null },
|
||||
{ json: false, encoding: null, useStream: true },
|
||||
);
|
||||
(returnData[index].binary as IBinaryKeyData)[binaryPropertyName] =
|
||||
await this.helpers.prepareBinaryData(
|
||||
|
|
Loading…
Reference in a new issue