Multiple files in one field for Form-Multipart-Data in an HTTP Request?

Describe the problem/error/question

I have a 2-step workflow I’m trying to make work, and I’m having trouble with the second step:

Step 1 (working, no problems):

Webhook taking in some form data, where the name “file” has multiple files on it. This looks like the following on a Postman:

And here’s a CURL of the same call:

curl --location --request POST 'https://automata.myn8ninstance.co/webhook-test/5f06c602-1cd6-4887-ab1c-712f0ddd3105' \
--header 'Authorization: Basic <AUTHHEADER>' \
--form 'data=@"/Users/me/Downloads/Hello World A.pages"' \
--form 'data=@"/Users/me/Downloads/Hello World B.pdf"'

The N8N webhook workflow receives it perfectly as two separate files:

Step 2 (not working)

Now, I want to do an HTTPS POST request to an API that takes in a formData field called “file” with multiple files.

I can get it working with one file:

But when i try to add in two files, it is overwriting file, not appending to it:

I have tried to put things like data0&data1 into Input Data Field Name, to no avail.

tl;dr:
I want to simulate something as simple as this CURL:

curl --location --request POST 'https://ipfs.infura.io:5001/api/v0/add?wrap-with-directory=true' \
--header 'Authorization: Basic <AUTH>' \
--form 'file=@"/Users/me/Downloads/FileA.pages"' \
--form 'file=@"/Users/me/Downloads/FileB.pdf"'

Where there are multiple pieces of data attached to file.

Also adding in the current full workflow I have if it helps. Removing some headers for privacy reasons, so sorry if you can’t call it!

Help would be much appreciated, thanks!

Hi @friendly-platypus :wave: Welcome to the community :cake:

Could you give something like this a try? It’ll split your attachments into three separate files called data, and then try to upload the data (along with your other fields) through the HTTP request.

The only other way around this I can think of would be to zip your attachments (n8n has a file compression node if you need it) and upload that singular file. If you’re self-hosting n8n and you’re handy with cURL, you could also use the Execute Command node as a workaround, too.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.