mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(HTTP Request Node): Duplicate key names support for form data (#9040)
Co-authored-by: Marcus <marcus@n8n.io>
This commit is contained in:
@@ -7,7 +7,13 @@ import type {
|
||||
|
||||
import set from 'lodash/set';
|
||||
|
||||
export type BodyParameter = { name: string; value: string };
|
||||
import FormData from 'form-data';
|
||||
|
||||
export type BodyParameter = {
|
||||
name: string;
|
||||
value: string;
|
||||
parameterType?: 'formBinaryData' | 'formData';
|
||||
};
|
||||
|
||||
export type IAuthDataSanitizeKeys = {
|
||||
[key: string]: string[];
|
||||
@@ -168,6 +174,22 @@ export const prepareRequestBody = async (
|
||||
set(result, entry.name, entry.value);
|
||||
return result;
|
||||
}, Promise.resolve({}));
|
||||
} else if (bodyType === 'multipart-form-data' && version >= 4.2) {
|
||||
const formData = new FormData();
|
||||
|
||||
for (const parameter of parameters) {
|
||||
if (parameter.parameterType === 'formBinaryData') {
|
||||
const entry = await defaultReducer({}, parameter);
|
||||
const key = Object.keys(entry)[0];
|
||||
const data = entry[key] as { value: Buffer; options: FormData.AppendOptions };
|
||||
formData.append(key, data.value, data.options);
|
||||
continue;
|
||||
}
|
||||
|
||||
formData.append(parameter.name, parameter.value);
|
||||
}
|
||||
|
||||
return formData;
|
||||
} else {
|
||||
return await reduceAsync(parameters, defaultReducer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user