url ftp 中的空格 node.js 中的客户端
spaces in url ftp client in node.js
我使用 ftp Node.js 并且我能够读取文件和文件夹,但只有它们的 URL 中的文件夹没有 spaces。
这个有效:
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);
但是,如果 var 路径有 space,则 无效 。
var path = "app/Laundry Machine";
我尝试输入 %20 或 +,但还是不行。
您可以使用 listSafe 方法代替列表。
"This is useful for servers that do not handle characters like spaces and quotes in directory names well for the LIST command."
我使用 ftp Node.js 并且我能够读取文件和文件夹,但只有它们的 URL 中的文件夹没有 spaces。
这个有效:
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);
但是,如果 var 路径有 space,则 无效 。
var path = "app/Laundry Machine";
我尝试输入 %20 或 +,但还是不行。
您可以使用 listSafe 方法代替列表。
"This is useful for servers that do not handle characters like spaces and quotes in directory names well for the LIST command."