# Read data file with non local path

**URL:** <https://discourse.nodered.org/t/read-data-file-with-non-local-path/39179>\
**Category:** General\
**Created:** [15 January 2021 14:13 UTC](https://discourse.nodered.org/t/read-data-file-with-non-local-path/39179 "2021-01-15T14:13:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gaberiel](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@Gaberiel](https://discourse.nodered.org/u/Gaberiel)\
**Post date:** [15 January 2021 14:13 UTC](https://discourse.nodered.org/t/read-data-file-with-non-local-path/39179/1 "2021-01-15T14:13:21Z")

</div>

Hello...I need a function to read the content of a file that has a different path (it's located in app online),  
the path is similar to this "data:text/plain;base64,c2FsdXQgICAuLmplIHN1aXMgSGFmc2EgQXJhYmJhdGU=", the 'file in' node can't recognize the path like this..So I'm wondering if I put this path as a variable in a function and read the file but I'm not good enough in JS ..any help? ![tst2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/c/cc8c77328b9941e3bd44c3706d41f9cf5be57792.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [15 January 2021 14:21 UTC](https://discourse.nodered.org/t/read-data-file-with-non-local-path/39179/2 "2021-01-15T14:21:48Z")

</div>

That is not a path. it is a bas64 encoded data

so you would split it at the comma and the base64decode everything after comma to get the text.

[https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics\_of\_HTTP/Data\_URIs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [15 January 2021 14:22 UTC](https://discourse.nodered.org/t/read-data-file-with-non-local-path/39179/3 "2021-01-15T14:22:39Z")

</div>

The file nodes (as you have found) only read local files. For web based resources you probably need the http-request node - but again that needs a proper url - what you have is an inline resource that is a base64 encoded piece of text. You would need to extract and decode the text first and then use that as a url.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [15 January 2021 14:57 UTC](https://discourse.nodered.org/t/read-data-file-with-non-local-path/39179/6 "2021-01-15T14:57:31Z")

</div>

A simple example

```auto
[{"id":"266aa7d2.820848","type":"change","z":"8d22ae29.7df6d","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$base64decode($split(payload,\",\")[1])","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":3920,"wires":[["2756679c.c38ed8"]]},{"id":"e80c63e9.b052e8","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"data:text/plain;base64,c2FsdXQgICAuLmplIHN1aXMgSGFmc2EgQXJhYmJhdGU=","payloadType":"str","x":130,"y":3860,"wires":[["266aa7d2.820848"]]},{"id":"2756679c.c38ed8","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":500,"y":3920,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Gaberiel](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@Gaberiel](https://discourse.nodered.org/u/Gaberiel)\
**Post date:** [15 January 2021 22:39 UTC](https://discourse.nodered.org/t/read-data-file-with-non-local-path/39179/7 "2021-01-15T22:39:53Z")

</div>

Thank you so much

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [29 January 2021 22:39 UTC](https://discourse.nodered.org/t/read-data-file-with-non-local-path/39179/8 "2021-01-29T22:39:56Z")

</div>

Closed on 29 January 2021 22:39 UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
