我试图从根文件夹下载ftp服务器上的每个文件. 我做的是这个 – ftpClient.ls(".", function(err, res) { res.forEach(function(file) { console.log(file.name); ftpClient.get("./"+file.name, 'D:/styleinc/ftp/'+file.name, fun
我做的是这个 –
ftpClient.ls(".", function(err, res) { res.forEach(function(file) { console.log(file.name); ftpClient.get("./"+file.name, 'D:/styleinc/ftp/'+file.name, function(hadErr) { if (hadErr) console.log(hadErr); else console.log('File copied successfully!'); }); });
但在运行时它给我错误 –
{ [Error: connect ECONNREFUSED] code: 'ECONNREFUSED', errno: 'ECONNREFUSED', syscall: 'connect', msg: 'Probably trying a PASV operation while one is in progress' }
我已经成功登录并在ftp网站上验证了自己的身份…..
我不知道该怎么办请指导我.
'use strict' var JSFtp = require('jsftp'); var inspect = require('util').inspect; var fs = require('fs'); var async = require('async'); var ftp = new JSFtp(require('./util/ftp')) var local = 'EDI/mohawk/OUTBOX/' var remote = 'OUTBOX' var gatherFiles = function(dir){ return new Promise(function(resolve, reject){ ftp.ls(dir + '/*', function(err, res) { if (err) reject(err) console.log(res) var files = []; res.forEach(function(file){ files.push(file.name) }); resolve(files) }) }) } gatherFiles(remote).then(function(files){ console.log(files) async.mapLimit(files, 1, function(file, callback){ console.log('attempting: ' +remote + file + '->' + local + file) ftp.get(remote +'/'+ file, local +'/'+ file, function(err){ if(err){ console.log('Error getting ' + file) callback(err) }else{ console.log('Got ' + file) callback() } }) }, function(err, res){ if(err){ console.log(err) } console.log('updates complete' + res) }) })