Paths in nodes for node-red local directory

I am stuck with using a node (ui_media) and how to set the path.

I am reading that I need to point to the public directory.

I've done this before with nodes to set background images on pages.
The difference is that that is set with me typing the path.

When I use ui_media, I get a file requester.
There is no ability (or I don't know how to) type the path, and as the node-red is a hidden directory, it isn't shown.

I've just double checked myself and clicking on the "ALL FILES" box (bottom right) does nothing..

So how do I navigate to the .node-red directory?

Reading the docs from the info page, I am trying another way.

msg.src

Is possible to switch media by msg.src, using a link http.

Example:
msg.src: "https://http.cat/200.jpg"

Nice, but I'm still missing something.

I put an inject, function and the ui_media node.

I use the function rather than the change node. Anyway.

So going on what the info says I put this in the function node:

The only thing I changed is the path so why it is giving this error about missing { } or : ....... etc?

As I've no doubt you know, the syntax to set a property in JavaScript is:

msg.src = "https://http.cat/200.jpg";

I can only assume the help for that node wasn't intending to give you literal code to copy, more trying to indicate what a suitable value for msg.src might look like.

1 Like

So if I am wanting to show a picture of:

/home/me/.node-red/public/Pictures/example.jpg

And the settings.js file is like this:

cat settings.js | grep public
    httpStatic: '/home/me/.node-red/public',

What should I put there?

(Sorry for the dumb question)

I get this from the ui_template node where I put pictures on the web page:

<style>
    body {
        background-image: url("/Pictures/metal_7.jpg");
        background-repeat: repeat;
    }
 </style>

But I can't equate that with the problem with msg.src

Don't worry.

I think I have nutted it out.

(Spoke too soon)
Kind of......

I have nutted out how to show pictures which are already existing in
.node-red/lib/ui-media/lib/Group$

But I am still unable to work out how to get remote pictures displayed in the node.

This is the effort to show a "remote" picture:

[{"id":"9f436463.05fb08","type":"inject","z":"baf80d2f.6bd538","name":"","topic":"","payload":"public/Pictures/wall.jpg","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":2720,"wires":[["e67d8904.5ed23"]]},{"id":"e67d8904.5ed23","type":"function","z":"baf80d2f.6bd538","name":"","func":"//msg.source: \"public/Pictures/wall.jpg\";\n\n// msg.src: \"https://http.cat/200.jpg\"\n//msg.src = \"https://192.168.0.6/home/me/Pictures/wall.jpg\";\nmsg.src = \"http://127.0.0.1/home/me/.node-red/public/Pictures/wall.jpg\";\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":2720,"wires":[["7faaccc8.d88894"]]},{"id":"7faaccc8.d88894","type":"fan","z":"baf80d2f.6bd538","x":470,"y":2630,"wires":[["10805068.2553c","da2b6a11.6ea448"]]}]

So all I would need to do is edit the line:
msg.src = "http://127.0.0.1/home/me/.node-red/public/Pictures/wall.jpg";
I've tried https too.
No luck.

Hi @Trying_to_learn

If the ui_template node is able to load an image using a url of "/Pictures/metal_7.jpg" then the full url will probably be: http://127.0.0.1:1880/Pictures/metal_7.jpg. Try opening that url in a new browser tab to see if it works.

That then suggests the url you want for your wall.jpg picture would be: http://127.0.0.1:1880/Pictures/wall.jpg.

If it doesn't work, then share with us the url you use to access the dashboard page.

Note I've picked 127.0.0.1 - if you are trying to load the dashboard from a different device, you'll need to replace that with the actual ip address of the device you are accessing.

1 Like

I didn't realise I needed the :1880 qualifier!

Just powered up now and tried.

Nice!

But.... Yeah, sorry. I think you know me well enough that there is always one of these.

All that gives me access to the node-red public directory.

I used 127.0.0.1 only to be sure it was local.

So changing it to the real IP address it also works.

But again: that is all local (and/or) using Node-Red's public path.

So I'm stuck when I want to access a picture on a remote machine.
The path on that machine won't be a node-red share.

So, strictly as an example:

This machine:
192.168.0.6
I want to see a picture from:
192.168.0.3
The image on that machine is in path:
/path1/path2/path3/picture.jpg

Sorry if how I named the paths is pitiful, but I want it to be clear for me when you reply.
(No offence to you) but I still am not getting a lot of the examples as I am not used to seeing it in that format.

I'll shut up now and stop digging the hole I am probably in.

Thanks again.

And yes, the :1880 bit got me for node-red paths.

If you want to serve images from another machine, is that machine also running Node-RED with its httpStatic setting properly configured? Or have you done something else to make the images accessable?

(This is going to sound weird, but.....)

I haven't got to that part yet.

This is probably more just brain working than a question at this stage.

But from an outside perspective I saw this media node as being able to show media on a dashboard, as I'm guessing something like a picture on a web page.
Background even.
Which is a bit weird as NR already supports that. :wink:

So it allows dynamic pictures or videos.

Ok...... Nice. If I have pictures on another machine (remote) I can access and see them.

Say a cache of pictures from a remote camera that is motion activated.

There seems to be a problem with how this all fits together in light of things learnt by me.

So: something happens, the motion camera is activated and it takes piccies.
They are stored somewhere.
(Probably not a good idea to be stored on that machine.)
The pictures are there awaiting inspection.

media would be a nice way to do it.

but (here he is)
that can only work if the pictures are stored on the same machine as the media node.
And are stored in the path from http:static and the extra bit it puts on the path.

So the problem/s I have since seen:
1 - media is mainly (ok, bad word. I'm working on it) used to view pictures/videos on the local machine as the path points into httpstatic.
1(b) - and to view these local files which are (probably) form another application, they have to be moved/copied(?) to that directory. duplicate! Though this can be seen as good as it separates the ones used my media to their original program, it seems to be making work for the sake of work.
2 - to access remote files on a non NR machine, sharing needs to be set up.
3 - to access remote files with NR, the files have to be put into the remote machine's httpstatic path.

Now and then I look in the library and look for interesting nodes which I think could be nice/useful to use/try.

I know that is not a good way to do things. Alas that is how I sometimes/usually (which?) do things to find a working solution.

I am hoping to soon set up a remote IP camera with auto uploading to another (secure/remote) machine and this looked like a neat solution to the mechanics of looking at the pictures.