As I did not find a good solution before, this is how you post a binary file to http-request. The solution is: make sure that payload always is a buffer and never a string. No need to do all kinds of binary or base64 conversions, just make sure always a buffer is sent and never a string.
I started with File Upload using HTTP Request node (flow) - Node-RED that works well for text-files. For a version that works with both text and binary data (and has some boundary-=optimizations), you need to replace the contents of Format the header and payload with:
Hi Vincent -- thanks for taking the time to post your solution! I, too, have spent a good bit of time trying to piece together a multipart/form-data compliant payload that my Spring apis would accept. I'm not sure why there is no editor panel for the core http-request node, that would allow the user to include an array of files, buffers, and key/value pairs... or why I never offered to contribute that feature... hmmm.
Lately I've been referring to this answer from Nick for a bit simpler JS function example. It does require that your binary data be in a Buffer, but it avoids the user generated boundaries and interspersed CR/NL bits that are hard to find when they are not perfectly placed.
The help sidebar for the HTTP Request node tells you how to do a file upload.
File Upload
To perform a file upload, msg.headers["content-type"] should be set to multipart/form-data and the msg.payload passed to the node must be an object with the following structure:
Biggest problem is that many nodes are at WFM-level. Then you get even situations like the complete msg being thrown away, or nodes that work under very specific situations only. A standard reaction is to fork to fix things quickly, but node-red-controb-xxx-3 gets abandoned too.
I'm working on multiple ones needed for interaction with gitlab and mattermost APIs.
Is there a design-doc for plugins? Are there ways to mark projects as abandoned?
Again we would encourage you to point them out more publicly (in a polite manner) rather than jump straight to forking so we can possibly "help" the author try to improve their nodes. The latest packaging details are here - Packaging : Node-RED - and the recent work on scoring is also looking at ways to take note of nodes that seem to be abandoned.