How to avoid "must contain a binary file 'data', but none was found [item 0]"?

Hello,
I’m really struggling on the parameter to pass into the “Input Data Field Name”
I searched on many topics and I didn’t find anything to get around the error i got… I tried to use a loop after the form upload node and I still get the same error.

I’ll explain, I want to upload multiple PDF at once, read every PDF files with Mistral OCR and ask an AI Agent if my folder is complete and if any PDF is missing based on a prompt.

The workflow is working well if I upload only 1 PDF. But I can’t find a way to make it work with multiple PDF… I read on some topics that we can split our 1rst result with one section of code but still got the same error with the code.
“This operation expects the node’s input data to contain a binary file ‘data’, but none was found [item 0]” when reaching the first Mistral Upload Node.

Here is my workflow :

Thanks

Information on your n8n setup

  • **n8n version: last
  • **Database (default: SQLite): none
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):own
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):cloud
  • **Operating system:windows

Hello @Octek Welcome to the community :tada:

Can you try this

it should work with multiple uploaded PDFss

Thanks for the answer mohamed3nan.

But no, it does not work.
If i upload only 1 PDF, it’s working
But if I upload multiple files I still got the error.

Here is the error when uploading multiple files :

can you please copy the code node because i edited it

The problem is that I don’t know what code to type to make it work :smiley:

That’s why I’m posting here :confused:

Things that I have tried :

  • Use a loop node after uploading multiple files
  • Use the “Split” node after uploading multiple files
  • Use some code (but don’t really know if the code I was using was working)

Either I don’t have the right piece of code or I don’t have the right parameter in the node Mistral Upload → On the “Input Data Field Name”.
I’m really struggling to get it working

this is the code to copy to your code node:

let results = [];

for (const item of $input.all()) {
    for (key of Object.keys(item.binary)) {
        results.push({
            json: {
                fileName: item.binary[key].fileName
            },
            binary: {
                data: item.binary[key],
            }
        });
    }
}

return results;

If you don’t want to use code, here is a very simple approach:

This setup splits the binary files:

and this correctly maps the input data field:

3 Likes

Oh great !
That’s working !

Thanks a lot for this, I think this trick is a “must have” for everyone working with multiple files at once !

Again, Thank you !

1 Like

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