Mqtt to save a file

i use mqtt to download an image to an another node red application.
I can display this file/image on my dashboard, but i can't save the file on the disk
can you help me ?

Have you tried sending the image data to a file node?

Maybe you could try posting your flow here?

this is my flow
i want just to save the file on my disk

no, i want to use the MQTT protocol.

Can you explain in more detail what you mean? MQTT is not a protocol for writing to disk. Unless you mean that you want the MQTT topic containing the image to be retained by the MQTT broker. In which case you can set the Retained flag when you publish it to MQTT.

i know mqtt is not a protocol for writting to disk. i just use this protocol to upload/dowload my image.
When i receive my data with the mqtt protocol, i just transform it to display my image into the dashboard.
that it is ok.
now, i just want save the file, not only display it on my dashbord. this is my problem.

Then use a File Out node to write it to the file as well as sending it to your template as @Steve-Mcl suggested.

Colin, i do that but i had an error when i trie to open the file with a file editor.

What sort of error? Wouldn't you be better to open it with an image viewer?

1 Like

Where is the file node? after the base64? If so, that is not gonna be valid image data.
Put the file node immediately after the mqtt node & try again. Additionally, set the filename to a location you are sure can be written. If it errors, post a screen shot. If you get an error opening the image in an image viewer, screen shot the error.

it is ok now. i just put the node behind the mqtt receiver and it is ok

just a remark, if i save the file with .jpeg, i have got a file with 239 ko and if i change the extension file with .JPEG have got a file with 716 ko.But i can open the both files, so it is ok for me now. I don't now why because i did that before... may be an update.
Thanks for your help... and sorry for my english :slight_smile:

Are you saying that in the flow you show, where you send the same message to two File nodes, that the two files end up with different lengths even though everything in the File nodes is the same except the name? That seems very surprising to me. Make sure you have not set Append to File in one of them.
If you are convinced this is happening export the flow and post it here.

i have set Append, i set Owerite, and now i have got same result.:slight_smile:

1 Like