# How to serve string from memory as a file?

**URL:** <https://discourse.nodered.org/t/how-to-serve-string-from-memory-as-a-file/101501>\
**Category:** General\
**Created:** [20 July 2026 16:55 UTC](https://discourse.nodered.org/t/how-to-serve-string-from-memory-as-a-file/101501 "2026-07-20T16:55:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DocPrinter](https://avatars.discourse-cdn.com/v4/letter/d/aca169/32.png) [@DocPrinter](https://discourse.nodered.org/u/DocPrinter)\
**Post date:** [20 July 2026 16:55 UTC](https://discourse.nodered.org/t/how-to-serve-string-from-memory-as-a-file/101501/1 "2026-07-20T16:55:19Z")

</div>

Hi,

I've followed examples which allow me to serve a file from node red dashboard/ui. What I would like to do is to just serve the file as a string direct from memory. Please can someone point me to an example, or explain why I shouldn't do this? I'm only talking about small to medium log files.

Thanks.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 July 2026 17:44 UTC](https://discourse.nodered.org/t/how-to-serve-string-from-memory-as-a-file/101501/2 "2026-07-20T17:44:48Z")

</div>

I don't fully understand what you are trying to do. Do you mean that you have a string in, for example, msg.payload and you want to show it on the dashboard? If so, just send it to a ui-text node.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 July 2026 17:46 UTC](https://discourse.nodered.org/t/how-to-serve-string-from-memory-as-a-file/101501/3 "2026-07-20T17:46:00Z")

</div>

Or if you mean that you want to send it to a file then use a file out node to do that.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 July 2026 18:03 UTC](https://discourse.nodered.org/t/how-to-serve-string-from-memory-as-a-file/101501/4 "2026-07-20T18:03:17Z")

</div>

Where does the string live? In Node-RED or in dashboard?

If it is in Node-RED, you can setup an endpoint (http-in --\> change node (put the string in payload) --\> http-response) (see endpoint examples in the Node-RED cookbook in the docs).

To make it a file, set the appropriate headers in the http-response node such that it has a file and content disposition

You can even do it dynamically in a function node

```auto
const logContent = "2026-07-20 INFO: System operational\n2026-07-20 ERROR: Connection failed" // or from context or wherever your log string is
const byteLength = Buffer.byteLength(logContent, 'utf-8');
const filename = 'system.log' // or dynamic like formated-time.log
msg.headers = {}
msg.headers['Content-Disposition'] = `attachment; filename="${filename}"`
msg.headers['Content-Type'] = 'application/octet-stream'
msg.headers['Content-Length'] = byteLength 
return msg

```

This would be passed to the http-response node

Then in your dashboard, you can use a simple anhor (hyperlink) that points to the endpoint

---

<div class="post-metadata">

**Author:** ![DocPrinter](https://avatars.discourse-cdn.com/v4/letter/d/aca169/32.png) [@DocPrinter](https://discourse.nodered.org/u/DocPrinter)\
**Post date:** [20 July 2026 20:27 UTC](https://discourse.nodered.org/t/how-to-serve-string-from-memory-as-a-file/101501/5 "2026-07-20T20:27:01Z")

</div>

@Colin Evening. Thanks for your reply. I wanted a user to be able to download some log data from the UI/webpage that is stored as a string in node-red. I have a working example already but it works by requesting a file from the system which it then downloaded by the user's browser.

I wasn't too comfortable about this as it requests from the file system which feels like a potential vunrability and I'm having to dump to file before that file is then read and sent over the network. Seemed counter productive.

Looks like the other poster may have a workable solution.

---

<div class="post-metadata">

**Author:** ![DocPrinter](https://avatars.discourse-cdn.com/v4/letter/d/aca169/32.png) [@DocPrinter](https://discourse.nodered.org/u/DocPrinter)\
**Post date:** [20 July 2026 20:29 UTC](https://discourse.nodered.org/t/how-to-serve-string-from-memory-as-a-file/101501/6 "2026-07-20T20:29:43Z")

</div>

@Steve-Mcl Evening. Thanks for your reply. That looks like what I am after, I will take aclose look at that.

---

<div class="post-metadata">

**Author:** ![DocPrinter](https://avatars.discourse-cdn.com/v4/letter/d/aca169/32.png) [@DocPrinter](https://discourse.nodered.org/u/DocPrinter)\
**Post date:** [26 July 2026 07:05 UTC](https://discourse.nodered.org/t/how-to-serve-string-from-memory-as-a-file/101501/7 "2026-07-26T07:05:22Z")

</div>

@Steve-Mcl Thanks that worked great.

---

<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:** [9 August 2026 07:06 UTC](https://discourse.nodered.org/t/how-to-serve-string-from-memory-as-a-file/101501/8 "2026-08-09T07:06:15Z")

</div>

Closed on 9 August 2026 07:06 UTC

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