Initiate Download without New Window

Hello All,

I have a flow that generates a ui-table of files available in a directory. When a user clicks on the file in the table, it is sent into a ui-template node that uses to navigate to the page where a file download is triggered. This works very well but there is a noticeable "flash" when the download starts from the window opening and closing quickly. Even though it is definitely nitpicky...I'm trying to remove it.

I've used window.location.href and this gives the functionality I want, but it causes the dashboard to disconnect and the page needs to be reloaded. Which makes sense as the href command is changing the location. I've tried several other solutions I've found by googling but they all result in either the brief flash, or the disconnect.

Is there another way to accomplish what I'm trying to do? Perhaps there a better way to initiate a download from Node-RED's local file system to the dashboard user's system, that still allows me to use the aesthetics of the ui-table?

I'm using the majority of This Example to serve the file for download.

I haven't used it for a while but uibuilder has an option that generates an index view of the instance root folder:


It uses a feature of ExpressJS I think. (Sorry, memory a bit vague on this since I set it up so long ago).

Probably not what you want. But if you look at the html source code of the page, you can see the URL's. It wouldn't be that hard to use a sub-folder of your uibuilder instance root folder to hold the files (you should be able to use a filing system folder link if you wanted to have the real folder somewhere else). Then build the HMTL list of links manually and send to your uibuilder page using the low-code feature. It wouldn't be very secure but it would get the job done.

There are likely several other ways you could use uibuilder to do this as well. It is probably possible to do something with just http-in/-out nodes too.

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