Search code examples
javascriptweb-applicationsnode.jswebos

Retrieving a file list from a remote file system with Node.js


Is it possible to retrieve a directory listing of a remote file-system using Node.js. I know how to do it locally using readdir(...) or readdirSync(...) but can I use those methods to return a list of remote files especially from a http or ftp server?

EDIT: I want to do this in webOS so I'm limited to the supported API's it seems. I may have to do some real round-a-bout method like have a script that creates a file that contains a list of files in the folder and just accessing that. So I guess that brings up a second question could I fire a remote script from a local script?


Solution

  • Sure. You could find an ftp client for node, then if your server has an ftp server going you can just interact with it.

    The following is how you might go about getting real filesystem access to a remote server

    If you have root access to the remote machine you are trying to interact with, yes it should be possible. Otherwise, no.

    I am not super familiar with all of this, but you will need to do something along the lines of:

    1. Configure a Network File System server (something like this) on your remote machine.
    2. Set up an NFS client on your local machine where node is being run and mount the network file system.
    3. Then i think, you should be able to use the node filesystem library to browse the network file system mounted locally as you would with the normal file system.