How to set images and save files in Node-Red using Ubuntu Core

#1

Hi!
I want to set local images in dashboard too, but I have node-red installed in one Dell 3003 series, using Ubuntu Core. I'm extremely new on this (on ubuntu, I refer) and I don't know in where file dispose the httpStatic direction neither how open the window where the change is done. I've tried to change the file settings.js located in /root/snap/node-red/{version}/settings.js but the httpStatic parameter isn't there.

I search for info and see the comand src or put the /image file in C: and refer to /myimage.png, so I have set my /image folder in /home/admin/image and transfered one ."png" image to there, but this doesn't show the image so I think I'm forgetting something...

Also, I want to save the data in a .csv file. I have done this in Windows with the .csv and file nodes, and it works perfectly but, again, I don't know hot to do this in Ubuntu Core.

Some help?

0 Likes

#2

Normally on Ubuntu the settings.js file (and your flows file) would be in the folder .node-red under your home folder, but I don't know whether it is different in Ubuntu Core. If you can run node-red then look in the node red log (again, not sure where that will be). If you can run it from a terminal it may be there. When node red is started it will output messages starting with "Welcome to node red" and in the lines after that it will say where the files are.
Is there a reason you want to use Ubuntu Core? If you are not used to Linux then it will generally be easier to get help if instead you used Ubuntu Server or Ubuntu Desktop, then you can install node-red using the Pi upgrade script and everything should just go.
In terms of where to put the static files you can put them anywhere that is accessible to node red. I put them in a subfolder of .node-red (.node-red/static) then in settings.js I put

httpStatic: '/home/myusername/.node-red/static/`

which, once you work out where your .node-red folder is you can modify that. accordingly.

0 Likes

#3

Hi Colin,
I'm programming this on my job and the PC there uses Ubuntu Core, only this reason.

Finally I set the pictures in base64 format, directly in the node as msg.payload, so this issue is solved for me.
On the other hand, still don't know where to set the folder to save data. I have already find the settings.js file and I'm able to change it, but the SSH client that I use displays the folder ".node-red" is on many folders... Which one I have to use?

0 Likes

#4

Post the node red startup log, starting with the Welcome to Node Red message. Put a line with three backtick characters before it and another such line after to stop the forum reformatting it.

0 Likes

#5

There goes:

root@4LVL902:/# snap run node-red
STARTING NODE-RED : /snap/node-red/x1/bin/node-red -u /root/snap/node-red/x1 on port 1880
31 Oct 17:06:26 - [info]

Welcome to Node-RED

31 Oct 17:06:26 - [info] Node-RED version: v0.19.4
31 Oct 17:06:26 - [info] Node.js version: v6.11.4
31 Oct 17:06:26 - [info] Linux 4.4.0-135-generic x64 LE
31 Oct 17:06:27 - [info] Loading palette nodes
31 Oct 17:06:29 - [warn] rpi-gpio : Raspberry Pi specific node set inactive
31 Oct 17:06:29 - [warn] rpi-gpio : Cannot find Pi RPi.GPIO python library
31 Oct 17:06:33 - [info] Dashboard version 2.9.8 started at /ui
31 Oct 17:06:33 - [warn] ------------------------------------------------------
31 Oct 17:06:33 - [warn] [node-red-contrib-s7comm/s7comm] SyntaxError: Unexpected token )
31 Oct 17:06:33 - [warn] ------------------------------------------------------
31 Oct 17:06:33 - [info] Settings file : /root/snap/node-red/x1/settings.js
31 Oct 17:06:33 - [info] HTTP Static : /home/admin/.node-red/static
31 Oct 17:06:33 - [info] Context store : 'default' [module=memory]
31 Oct 17:06:33 - [info] User directory : /root/snap/node-red/x1
31 Oct 17:06:33 - [warn] Projects disabled : editorTheme.projects.enabled=false
31 Oct 17:06:33 - [info] Flows file : /root/snap/node-red/x1/flows.json
31 Oct 17:06:33 - [info] Server now running at http://127.0.0.1:1880/

0 Likes

#6

OK, so that shows us where the settings and flow files are. Did you edit that settings file and put the http static line in? If so then I presume that means that /home/admin/.node-red/static is where you want to put the images, did you have a good reason for putting them there? I don't understand what you mean by "the SSH client that I use displays the folder ".node-red" is on many folders". When you connect via ssh which folder does it open in? Run pwd to see, if you don't know.

0 Likes

#7

Well, I only set this line because you said:
"In terms of where to put the static files you can put them anywhere that is accessible to node red."
So I assume this folder has to be set after a .node-red folder.
Can I set this route in /home/admin/Backup/ ? or where I want to?

I refer this:
root@4LVL902:/# whereis .node-red
: /usr/bin/. /usr/sbin/. /usr/lib/. /bin/. /sbin/. /etc/. /lib/. /lib64/. /usr/games/. /usr/local/bin/. /usr/local/sbin/. /usr/local/etc/. /usr/local/lib/. /usr/local/games/. /usr/include/. /usr/local/. /usr/share/. /snap/bin/.

I think is displaying the folder .node-red is in all this folders, but I search in all and no results.

When run ssh it opens in /admin, but then I set "sudo su" to enter at root mode.

0 Likes

#8

To repeat my words that you quoted "In terms of where to put the static files you can put them anywhere that is accessible to node red." so yes you can put them wherever you like, provided that folder is accessible to node red. Which folders are accessible to node-red running in a snap in Ubuntu Core I have no idea. Presumably whoever decreed that the machine should have Ubuntu Core on it would know more about that environment.
The whereis command does not do what you think. You could use find or locate to do what you want.

0 Likes