Use constant for encoding

This commit is contained in:
Jan Oberhauser 2020-03-20 22:47:47 +01:00
parent 8d8b9c9652
commit 122a0c79a3

View file

@ -1,4 +1,5 @@
import { import {
BINARY_ENCODING,
IWebhookFunctions, IWebhookFunctions,
} from 'n8n-core'; } from 'n8n-core';
@ -330,7 +331,7 @@ export class Webhook implements INodeType {
const fileContent = await fs.promises.readFile(files[file].path); const fileContent = await fs.promises.readFile(files[file].path);
const buffer = Buffer.from(fileContent); const buffer = Buffer.from(fileContent);
set(returnData[0], `binary[${fileName}]`, { set(returnData[0], `binary[${fileName}]`, {
data: buffer.toString('base64'), data: buffer.toString(BINARY_ENCODING),
mimeType: fileJson.type, mimeType: fileJson.type,
fileName: fileJson.name, fileName: fileJson.name,
fileExtension, fileExtension,
@ -357,7 +358,7 @@ export class Webhook implements INodeType {
response.binary = { response.binary = {
data: { data: {
// @ts-ignore // @ts-ignore
data: req.rawBody.toString('base64'), data: req.rawBody.toString(BINARY_ENCODING),
mimeType, mimeType,
} }
}; };