In the documentation I cannot find any complete information on how to accept a file (main problem), convert it to base64 and send it to an API in a custom node. Can it be done with the declarative API? If no, how to do it with the programmatic API? Thanks in advance
To accept a file, convert it to Base64, and send it to an API, you’ll need to use the programmatic API in n8n. The declarative API may not cover all the steps involved in file handling and encoding.
You can start by using a webhook or HTTP node to accept the file, then use a “Function” node to convert the file to a Base64 string. Finally, use the “HTTP Request” node to send the Base64-encoded file to the desired API.
I want to do this in a custom node (Tutorial: Build a programmatic-style node | n8n Docs), not a workflow.
I assume you want to achieve input file, and convert from binary to base64, and directly send to API in a single custom node.
So, if you want to accept a file and directly covert to base64 and send it to API in a single custom node, you need to do three steps.
- Use
stringtype to accept the file - Create function for convert it to base64 (use extract from file node as reference)
- Do request to API
You can use these references to help your work:
You need to learn about Rest API too if you want to do it in a single node.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.