Initial changes for binary data management (#2105)

* introduce binary data management

* cr

* add binary data changes to awsS3 node

* add binary data changes to Box node

* add binary data changes to CiscoWebex node

* add binary data changes to HumaniticAi node

* add binary data changes to Jira node

* add binary data changes to Line node

* add binary data changes to MicrosoftOneDrive node

* add binary data changes to MicrosoftOutlook node

* add binary data changes to Mindee node

* add binary data changes to NocoDB node

* add binary data changes to Pushbullet node

* add binary data changes to Pushover node

* add binary data changes to Raindrop node

* add binary data changes to S3 node

* add binary data changes to Salesforce node

* add binary data changes to Ssh node

* add binary data changes to TheHive node

* add binary data changes to Twist node

* add binary data changes to Twitter node

* remove changes not needed right now

* 🐛 Fix issue with multiple runs

* 🐛 Revert fix and add support for multiple inputs

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Ahsan Virani
2021-08-20 18:08:40 +02:00
committed by GitHub
parent 7da86641d5
commit 178235e148
24 changed files with 103 additions and 66 deletions

View File

@@ -34,9 +34,10 @@ export interface IProcessMessage {
export interface IExecuteFunctions extends IExecuteFunctionsBase {
helpers: {
prepareBinaryData(binaryData: Buffer, filePath?: string, mimeType?: string): Promise<IBinaryData>;
request: requestPromise.RequestPromiseAPI,
requestOAuth2(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions, oAuth2Options?: IOAuth2Options): Promise<any>, // tslint:disable-line:no-any
requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | requestPromise.RequestPromiseOptions): Promise<any>, // tslint:disable-line:no-any
getBinaryDataBuffer(itemIndex: number, propertyName: string): Promise<Buffer>;
request: requestPromise.RequestPromiseAPI;
requestOAuth2(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions, oAuth2Options?: IOAuth2Options): Promise<any>; // tslint:disable-line:no-any
requestOAuth1(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUrl | requestPromise.RequestPromiseOptions): Promise<any>; // tslint:disable-line:no-any
returnJsonArray(jsonData: IDataObject | IDataObject[]): INodeExecutionData[];
};
}

View File

@@ -59,6 +59,21 @@ const requestPromiseWithDefaults = requestPromise.defaults({
timeout: 300000, // 5 minutes
});
/**
* Returns binary data buffer for given item index and property name.
*
* @export
* @param {ITaskDataConnections} inputData
* @param {number} itemIndex
* @param {string} propertyName
* @param {number} inputIndex
* @returns {Promise<Buffer>}
*/
export async function getBinaryDataBuffer(inputData: ITaskDataConnections, itemIndex: number, propertyName: string, inputIndex: number): Promise<Buffer> {
const binaryData = inputData['main']![inputIndex]![itemIndex]!.binary![propertyName]!;
return Buffer.from(binaryData.data, BINARY_ENCODING);
}
/**
* Takes a buffer and converts it into the format n8n uses. It encodes the binary data as
* base64 and adds metadata.
@@ -763,6 +778,9 @@ export function getExecuteFunctions(workflow: Workflow, runExecutionData: IRunEx
},
helpers: {
prepareBinaryData,
getBinaryDataBuffer(itemIndex: number, propertyName: string, inputIndex = 0): Promise<Buffer> {
return getBinaryDataBuffer.call(this, inputData, itemIndex, propertyName, inputIndex);
},
request: requestPromiseWithDefaults,
requestOAuth2(this: IAllExecuteFunctions, credentialsType: string, requestOptions: OptionsWithUri | requestPromise.RequestPromiseOptions, oAuth2Options?: IOAuth2Options): Promise<any> { // tslint:disable-line:no-any
return requestOAuth2.call(this, credentialsType, requestOptions, node, additionalData, oAuth2Options);