# Paths in nodes for node-red local directory

**URL:** <https://discourse.nodered.org/t/paths-in-nodes-for-node-red-local-directory/9999>\
**Category:** General\
**Created:** [10 April 2019 21:46 UTC](https://discourse.nodered.org/t/paths-in-nodes-for-node-red-local-directory/9999 "2019-04-10T21:46:50Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [10 April 2019 21:46 UTC](https://discourse.nodered.org/t/paths-in-nodes-for-node-red-local-directory/9999/1 "2019-04-10T21:46:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [10 April 2019 22:04 UTC](https://discourse.nodered.org/t/paths-in-nodes-for-node-red-local-directory/9999/2 "2019-04-10T22:04:08Z")

</div>

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](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?

 ![Screenshot%20from%202019-04-11%2007-56-04](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/5e8819b5422e8449742dbd1ecab675632315dd79.png)

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [10 April 2019 22:16 UTC](https://discourse.nodered.org/t/paths-in-nodes-for-node-red-local-directory/9999/3 "2019-04-10T22:16:24Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [11 April 2019 05:36 UTC](https://discourse.nodered.org/t/paths-in-nodes-for-node-red-local-directory/9999/4 "2019-04-11T05:36:06Z")

</div>

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:

```auto
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:

```auto
<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`

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [11 April 2019 06:11 UTC](https://discourse.nodered.org/t/paths-in-nodes-for-node-red-local-directory/9999/5 "2019-04-11T06:11:45Z")

</div>

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:

```auto
[{"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.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [11 April 2019 08:03 UTC](https://discourse.nodered.org/t/paths-in-nodes-for-node-red-local-directory/9999/6 "2019-04-11T08:03:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [11 April 2019 09:05 UTC](https://discourse.nodered.org/t/paths-in-nodes-for-node-red-local-directory/9999/7 "2019-04-11T09:05:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [11 April 2019 10:14 UTC](https://discourse.nodered.org/t/paths-in-nodes-for-node-red-local-directory/9999/8 "2019-04-11T10:14:04Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [11 April 2019 11:30 UTC](https://discourse.nodered.org/t/paths-in-nodes-for-node-red-local-directory/9999/9 "2019-04-11T11:30:07Z")

</div>

(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. 😉

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.
