Skip to content
Advertisement

Example node.js ftp server?

I need to create a node.js app that connects to this ftp server and downloads files from this directory:

ftp://www.ngs.noaa.gov/cors/rinex/2021/143/nynb

I’ve tried following the ftp npm package docs but I feel like I am doing something horribly wrong:

JavaScript

When I run npm run dev with nodemon I get:

JavaScript

Can someone please help? I’m completely stumped.

Is it possible if someone could show me a small example of how I can connect to this remote ftp server?

Advertisement

Answer

There are a few points :

  • You’re connecting to the local ftp with c.connect();. You need to connect to www.ngs.noaa.gov to download files from there.
  • This path cors/rinex/2021/143/nynb is a directory on the remote host. c.get doesn’t work, you need to list all files in the directory then download them 1 by 1.

The code below connect to the remote server and list all files in the directory

JavaScript
Advertisement