UNPKG

n8n-nodes-base

Version:

Base nodes of n8n

44 lines 1.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.description = void 0; exports.execute = execute; const utilities_1 = require("../../../../utils/utilities"); const descriptions_1 = require("../../descriptions"); const transport_1 = require("../../transport"); const properties = [descriptions_1.logRLC, descriptions_1.attachmentsUi]; const displayOptions = { show: { resource: ['log'], operation: ['addAttachment'], }, }; exports.description = (0, utilities_1.updateDisplayOptions)(displayOptions, properties); async function execute(i) { const logId = this.getNodeParameter('logId', i, '', { extractValue: true }); const inputDataFields = this.getNodeParameter('attachmentsUi.values', i, []).map((entry) => entry.field.trim()); const attachments = []; for (const inputDataField of inputDataFields) { const binaryData = this.helpers.assertBinaryData(i, inputDataField); const dataBuffer = await this.helpers.getBinaryDataBuffer(i, inputDataField); attachments.push({ value: dataBuffer, options: { contentType: binaryData.mimeType, filename: binaryData.fileName, }, }); } await transport_1.theHiveApiRequest.call(this, 'POST', `/v1/log/${logId}/attachments`, undefined, undefined, undefined, { Headers: { 'Content-Type': 'multipart/form-data', }, formData: { attachments, }, }); const executionData = this.helpers.constructExecutionMetaData((0, utilities_1.wrapData)({ success: true }), { itemData: { item: i }, }); return executionData; } //# sourceMappingURL=addAttachment.operation.js.map