spaces in url ftp client in node.js

572 views Asked by At

I use ftp Node.js and I'm able to read files and folders but only folders in their URLs there is no spaces.

this works:

var ftp = require('ftp');
var path = "app/LaundryMachine";
var client = new ftp();
    //connect properties
    var config = {
        host: '***.net',
        port: 21,
        user: '***',
        password: '***'
    };
    client.on('ready', function () {
            client.list(path, function (err, list) {
                if (err) throw err;
                for (var i in list) {
                    console.log(list[i].name);
                }

                client.end();
            });
    });
    client.connect(config);

but, if the var path have space it's not work.

var path = "app/Laundry Machine";

I try to put %20 or +, but still not.

1

There are 1 answers

0
Molda On BEST ANSWER

You can use listSafe method instead of list.

From npmjs.org/package/ftp

"This is useful for servers that do not handle characters like spaces and quotes in directory names well for the LIST command."