I’m building a workflow in n8n to allow users to upload files (e.g., PDFs) via a Webhook and then pass that file to OpenAI’s “Upload a File” node (for Assistant-based classification using purpose: assistants).
While testing, the Webhook successfully received the file, but my Function node (used to normalize the binary key) kept throwing:
Error: No binary file found.
Even though I verified in a debug node that the binary key existed ("file"), it wasn’t getting passed correctly to the OpenAI node, which expects the binary key to be file.
Accept a file from a user (via curl or form)
Normalize the incoming binary key to file
Pass it directly to OpenAI’s “Upload a File” node without errors
Using a JS Function node with Object.keys($binary)[0] would return red errors if binary wasn’t present or key mismatched
Using “Run Once for Each Item” in the Function node while returning an array caused structure mismatches
Any merge nodes or filters between Webhook and OpenAI stripped out binary unintentionally
First, you need to change the modes of your Code nodes to work with each item individually.
This is the node $json and $binary would only work.
In Run once for all items mode the proper way to get all inbound items (even if there is only one in fact) is $input.all() which returns an array of items, each having a json and, optionally, a binary key. Note the lack of $ in this scenario.
Second, you cannot simply move binary data to json. n8n stops seeing this data as binary entry.
What is it that try to achieve by normalizing the binary key?
It would be helpful if you could post your workflow using the </> button instead of screenshots. This would make it much easier for others to copy your workflow, patch it, and repost corrected version back here.
if any of the proposals/comments above helped you to resolve your initial question, please mark the relevant post as a Solution. This way future readers figure a solution to a problem similar to the one you had.