First of all, a little introduction to my system.
I am using a docker container to run several services, one of them is obviously NodeRED.
here I use an amazing node-red-contrib-uibuilder to pull up my interface with HTML, CSS, and JS language (No Vue or React is used).
I go straight to the problem
I would like to upload, from this interface, a CSV / TXT file and store it in a server-side folder.
Interestingly, Socket.IO has a binary file transfer capability, I didn't know that. I'll add it to the roadmap as something to maybe enable in uibuilder so that you can send a file as a buffer.
Without an http response node at the end of your flow, the browser never gets an answer and keeps waiting until it times out (in 90 secs or so) with a 504 Gateway Timeout status (iirc)
You can set the response code in your http response node to be 204 (No Content) in order to keep from navigating to an empty page.
Thank you both guys @shrickus and @TotallyInformation.
The main problem was related to the missing feature multipart/form-data.
I still need to work to extract filename and path to correctly store it, but I can handle it.
Regarding the keep loading issue, as from @shrickus, I trayed to add an HTTP response node.
It works perfectly, but I would like to keep seeing the same page of the form. Do you have some more advice?
Those fields are already parsed for you by node-red, and are available on msg.req.files, I believe. Change your debug node to show the "Complete msg object" and you will find what you need.
This flow works but you will want to change the filename slightly since it currently dumps the file in the Node-RED install folder.
I can confirm that the actual page is NOT reloaded - that's good since it doesn't lose any live data on the page. However, you will want to have a script that empties the filename so that people don't keep uploading the same file.
Going to write this up on the uibuilder WIKI for future use.
The transfer is only secure if you make it so. You need to at least implement TLS encryption (e.g. use HTTPS not HTTP). Then you should also validate the upload data before blindly assuming that it is safe. For example, check the file mimetype matches the filename extension, block unsafe file types (or better still have an allow list of types), limit the filename length and characters, limit the buffer size.
You should also only be allowing updates from known and authenticated users.
You might also want to have checks of available storage before committing the file and some other process to clear down old files or limit space utilisation.
So something is creating a delay between your client and the server. Most commonly, this is due to trying to pass really large data in a single msg.
One way to fix that would be to split your file in the client code if it is too large and then send each of the pieces and put them back together in node-red.
The other way requires you to mess with the socket.io server settings. Under uibuilder v4, there is no mechanism for that I'm afraid - unless you manually hack the appropriate uibuilder source file.
However, if you are prepared to run a beta version, you could install the GitHub vNext branch which is what will soon be uibuilder v5. In this version, you can supply settings for socket.io by adding the suitable properties to settings.js. It might be worth you creating a test instance of node-red with uibuilder vNext and trying it out to make sure it works.