refactor: Format nodes-base package (A-F) (#3800)
* 🔨 prettier formated nodes - A * 🔨 prettier formated nodes - B * ⚡ prettier formated nodes - C * ⚡ prettier formated nodes - D * ⚡ prettier formated nodes - E-F * 🎨 Adjust nodes-base formatting command (#3805) * Format additional files in nodes A-F (#3811) * ⚡ fixes * 🎨 Add Mindee to ignored dirs Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
@@ -1,15 +1,8 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
apiRequest,
|
||||
} from '../../../transport';
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function download(this: IExecuteFunctions, index: number) {
|
||||
const body: IDataObject = {};
|
||||
@@ -24,11 +17,14 @@ export async function download(this: IExecuteFunctions, index: number) {
|
||||
const endpoint = `files/${fileId}/`;
|
||||
|
||||
//response
|
||||
const response = await apiRequest.call(this, requestMethod, endpoint, body, {} as IDataObject,
|
||||
{ encoding: null, json: false, resolveWithFullResponse: true });
|
||||
const response = await apiRequest.call(this, requestMethod, endpoint, body, {} as IDataObject, {
|
||||
encoding: null,
|
||||
json: false,
|
||||
resolveWithFullResponse: true,
|
||||
});
|
||||
|
||||
let mimeType = response.headers['content-type'] as string | undefined;
|
||||
mimeType = mimeType ? mimeType.split(';').find(value => value.includes('/')) : undefined;
|
||||
mimeType = mimeType ? mimeType.split(';').find((value) => value.includes('/')) : undefined;
|
||||
const contentDisposition = response.headers['content-disposition'];
|
||||
const fileNameRegex = /(?<=filename=").*\b/;
|
||||
const match = fileNameRegex.exec(contentDisposition);
|
||||
@@ -52,7 +48,11 @@ export async function download(this: IExecuteFunctions, index: number) {
|
||||
}
|
||||
|
||||
newItem.binary = {
|
||||
[output]: await this.helpers.prepareBinaryData(response.body as unknown as Buffer, fileName, mimeType),
|
||||
[output]: await this.helpers.prepareBinaryData(
|
||||
response.body as unknown as Buffer,
|
||||
fileName,
|
||||
mimeType,
|
||||
),
|
||||
};
|
||||
|
||||
return this.prepareOutputData(newItem as unknown as INodeExecutionData[]);
|
||||
|
||||
Reference in New Issue
Block a user