-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FTP.ls returning empty array #287
Comments
Got same error |
I didnt have the time to debug it, ended up making my own little wrapper |
@jdalrymple are you parsing raw list? Can you share solution please. |
import Promise from 'bluebird';
import fs from 'fs';
import FTP from 'ftp';
class FTPClient {
constructor({ user, pass, host }) {
if (!(host && user)) {
throw new Error('Missing required params');
}
this.user = user;
this.pass = pass;
this.host = host;
}
get(path, output) {
const c = new FTP();
return new Promise((resolve, reject) => {
c.on('ready', () => {
c.get(path, (err, stream) => {
if (err) reject(err);
let contents = null;
if (!output) {
contents = '';
stream.on('data', (chunk) => { contents += chunk; });
} else {
stream.pipe(fs.createWriteStream(output));
}
stream.once('close', () => {
resolve(contents);
});
});
});
c.connect({ user: this.user, host: this.host, password: this.pass });
}).finally(() => { c.end(); });
}
list(path) {
const c = new FTP();
return new Promise((resolve, reject) => {
c.on('ready', () => {
c.list(path, (err, list) => {
if (err) reject(err);
resolve(list);
});
});
c.connect({ user: this.user, host: this.host, password: this.pass });
}).finally(() => { c.end(); });
}
put(input, destination) {
const c = new FTP();
return new Promise((resolve, reject) => {
c.on('ready', () => {
c.put(input, destination, (err) => {
if (err) reject(err);
resolve();
});
});
c.connect({ user: this.user, host: this.host, password: this.pass });
}).finally(() => { c.end(); });
}
upload(path, outputPath) {
return this.put(path, outputPath);
}
}
export default FTPClient; Example const client = new FTPClient(credentials);
let filenames = await client.list(ftpPath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Summary
When using the ls function, the return is always an empty array. If i use the list function, i see all the directories contents.
I've also tested by using the parse-listing library on the .list functions results and this seems to work well, so im unsure as to why the ls function is returning no results
The text was updated successfully, but these errors were encountered: