0

I have a remote directory on 'xyz.com/myimages/'. This directory has many files in it.

I would like to use my Node.js app to retrieve this list of file names from that URL (xyz.com/myimages/). I have verified that Apache is configured to permit directory indexing for this path.

How can I retrieve the file names form the URL using Node.JS?

David Hoelzer
  • 15,862
  • 4
  • 48
  • 67
Aron Suarez
  • 33
  • 1
  • 11

2 Answers2

1

If you have an SSH access you can do this like this:

var exec = require('child_process').exec;

exec("ssh login@xyz.com 'ls /path/to/myimages'",
  function (error, stdout, stderr) {
    console.log('remote files: ' + stdout);
  });
Talgat Medetbekov
  • 3,741
  • 1
  • 19
  • 26
  • thanks for answer, i don't have an ssh access to this server. the only way is over http with enabled directory listings.(is not my server, is from a customer) is there a solution for this? thanks for help – Aron Suarez May 11 '15 at 19:05
  • I'm just thinking, can you just parse that `URL` and extract a directories from it with regexp? – Talgat Medetbekov May 12 '15 at 17:49
0

IMHO , Better way is to use library like https://github.com/mscdex/ssh2 . It can provide a more programatic handle to operations on the machine than exec .

Raghavan
  • 883
  • 1
  • 8
  • 19
  • thanks for answer, i don't have an ssh access to this server. the only way is over http with enabled directory listings.(is not my server, is from a customer) is there a solution for this? thanks for help – Aron Suarez May 11 '15 at 19:02