[SOLVED]Download a file from Ninox into Node-RED (Windows)

I am trying to use the node-red-contrib-ninox plug-in to download a file from my Ninox database. This just works fine for getting records but when downloading a file Node-RED completly shuts down and I have to restart it on command line.

  • running Node-RED v1.3.5 with Windows Server 2019
  • using node-red-contrib-ninox -v0.99.11
  • downloaded and tried the example flows of the plug-in
  • set up the node the right way, because I can exchange record entries

There is not much information on google or its just refering to the node documentation inside the web interface which I already read.

I really hope someone can give me a helping hand or a hint how I could achieve this another way


7 Jul 21:45:27 - [info] Started flows
url https://api.ninoxdb.de/v1/teams/notsavetoshare/tables/L/records/23 headers {
  Authorization: 'Bearer notsavetoshare',
  'Content-Type': 'application/json'
url https://api.ninoxdb.de/v1/teams/notsavetoshare/tables/I/records/9 headers {
  Authorization: 'Bearer notsavetoshare',
  'Content-Type': 'application/json'
7 Jul 21:45:45 - [red] Uncaught Exception:
7 Jul 21:45:45 - Error: Command failed: mkdir -p tmpfiles/wgz9t4ldqm; curl --header "Authorization: Bearer maybenotsavetoshare" https://api.ninoxdb.de/v1/teams/notsavetoshare/tables/L/records/23/files/L23/it.pdf -o tmpfiles/wgz9t4ldqm/L23/it.pdf;

    at ChildProcess.exithandler (child_process.js:319:12)
    at ChildProcess.emit (events.js:375:28)
    at maybeClose (internal/child_process.js:1055:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)

What does the command line show when node-red crashes. There will be vital clues that you could raise with the author to get it fixed.

Also, what node-red version and node js versions are you running?

Thank you steve! yes I should have provided this information from the beginning and attached it to the main message

You should raise an issue on the repo.

However, you might be able to fix this by creating a folder tmpfiles and ensure node-red has permission to write to it.

assuming tmpfiles should be created inside User directory : \Users\USERNAME\.node-red but nothing on the error log changes.

I think this is Windows related and the javascript should execute mkdir -p tmpfiles\test & curl --header "Authorization: Bearer Secret-Ninox-API-KEY" https://api.ninoxdb.de/v1/teams/noonecares/tables/L/records/23/files/it.pdf -o tmpfiles/test/it.pdf

I have never raised an issue to a repository ... where can I do that - sry super noob question

There is a link to the repo on the npm & flows page.

But it probably shouldn't be shelling out to curl anyway (which I'm 99.9% sure won't be installed on your windows machine either)


Yep, big warning flags in the source:

          // TODO: use javascript instead of curl to download file
          // request.get({ url, headers }, responseHandlerFile);
          const exec = require('child_process').exec;
          const cmd = `mkdir -p ${tmpdir}; curl --header "Authorization: ${headers["Authorization"]}" ${url} -o ${fname};`;
          exec(cmd, (e, stdout, stderr) => {
            if (e instanceof Error) {
              throw e;
            msg.pathname = fname;
1 Like

You guys made my day! Thank you so much steve and hardillb!
I was astonished myself that curl runs exactly the same way in Windows

In Linux you combine two commands with COMMAND1;COMMAND2 but in Windows it should be COMMAND1 & COMMAND2 . I adapted this in const cmd and adjusted the const tmpdir and fname to the Windows file system in the script


          const tmpdir = `C:\\Users\\USERNAME\\.node-red\\tmpfiles`;
          const fname = `${tmpdir}\\${msg.filename}`;
          url += `records/${nid}/files/${msg.filename}`;
          // TODO: use javascript instead of curl to download file
          // request.get({ url, headers }, responseHandlerFile);
          const exec = require('child_process').exec;
          const cmd = `mkdir -p ${tmpdir} & curl --header "Authorization: ${headers["Authorization"]}" ${url} -o ${fname} &`;

Node-RED is not shutting down anymore and the whole flow is running like a charm :man_cartwheeling:

1 Like

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