UNPKG

@digitalstories/n8n-nodes-infomaniak

Version:

n8n nodes to interact with Infomaniak services (Kchat)

37 lines 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.uploadFile = uploadFile; exports.getFileDetails = getFileDetails; async function uploadFile(i, baseURL) { const channelId = this.getNodeParameter('channelId', i); const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i); const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName); const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); const formData = { channel_id: channelId, files: { value: dataBuffer, options: { filename: binaryData.fileName, contentType: binaryData.mimeType, }, }, }; const response = await this.helpers.requestWithAuthentication.call(this, 'infomaniakApi', { method: 'POST', url: `${baseURL}/api/v4/files`, formData, json: true, }); return response; } async function getFileDetails(i, baseURL) { const fileId = this.getNodeParameter('fileId', i); const response = await this.helpers.requestWithAuthentication.call(this, 'infomaniakApi', { method: 'GET', url: `${baseURL}/api/v4/files/${fileId}`, json: true, }); return response; } //# sourceMappingURL=FileOperations.js.map