mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
feat(core): Allow customizing max file size in form-data payloads for webhooks (#10857)
This commit is contained in:
parent
aa00d9c2ae
commit
a3335e0ecd
|
@ -65,6 +65,10 @@ export class EndpointsConfig {
|
||||||
@Env('N8N_PAYLOAD_SIZE_MAX')
|
@Env('N8N_PAYLOAD_SIZE_MAX')
|
||||||
payloadSizeMax: number = 16;
|
payloadSizeMax: number = 16;
|
||||||
|
|
||||||
|
/** Max payload size for files in form-data webhook payloads in MiB */
|
||||||
|
@Env('N8N_FORMDATA_FILE_SIZE_MAX')
|
||||||
|
formDataFileSizeMax: number = 200;
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
metrics: PrometheusMetricsConfig;
|
metrics: PrometheusMetricsConfig;
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,7 @@ describe('GlobalConfig', () => {
|
||||||
formTest: 'form-test',
|
formTest: 'form-test',
|
||||||
formWaiting: 'form-waiting',
|
formWaiting: 'form-waiting',
|
||||||
payloadSizeMax: 16,
|
payloadSizeMax: 16,
|
||||||
|
formDataFileSizeMax: 200,
|
||||||
rest: 'rest',
|
rest: 'rest',
|
||||||
webhook: 'webhook',
|
webhook: 'webhook',
|
||||||
webhookTest: 'webhook-test',
|
webhookTest: 'webhook-test',
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
/* eslint-disable prefer-spread */
|
/* eslint-disable prefer-spread */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||||
|
import { GlobalConfig } from '@n8n/config';
|
||||||
import type express from 'express';
|
import type express from 'express';
|
||||||
import formidable from 'formidable';
|
import formidable from 'formidable';
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
|
@ -214,9 +215,11 @@ export async function executeWebhook(
|
||||||
if (!binaryData) {
|
if (!binaryData) {
|
||||||
const { contentType, encoding } = req;
|
const { contentType, encoding } = req;
|
||||||
if (contentType === 'multipart/form-data') {
|
if (contentType === 'multipart/form-data') {
|
||||||
|
const { formDataFileSizeMax } = Container.get(GlobalConfig).endpoints;
|
||||||
const form = formidable({
|
const form = formidable({
|
||||||
multiples: true,
|
multiples: true,
|
||||||
encoding: encoding as formidable.BufferEncoding,
|
encoding: encoding as formidable.BufferEncoding,
|
||||||
|
maxFileSize: formDataFileSizeMax,
|
||||||
// TODO: pass a custom `fileWriteStreamHandler` to create binary data files directly
|
// TODO: pass a custom `fileWriteStreamHandler` to create binary data files directly
|
||||||
});
|
});
|
||||||
req.body = await new Promise((resolve) => {
|
req.body = await new Promise((resolve) => {
|
||||||
|
|
Loading…
Reference in a new issue