使用“ ftp”包将文件从“然后上传文件”下载到FTP服务器

问题描述

我正在研究一个系统,该系统每隔1分钟自动从FTP服务器读取CSV文件,将其转换为XML文件,然后将XML文件存储到FTP服务器。我正在使用txt文件进行测试。但是,我仍然遇到此错误

@H_502_2@
if (err) throw err;
         ^
Error: Unable to make data connection
    at Socket.<anonymous>

这是我的代码

@H_502_2@
const cron = require("node-cron");
const express = require("express");
var Client = require('ftp');
var fs = require('fs');

app = express();

// schedule tasks to be run on the server
cron.schedule("* * * * *",function () {
    console.log("Running Cron Job");

    var c = new Client();

    var connectionProperties = {
        host: "192.168.1.101",user: "Smoke2eZ",password: "Ngoclinh2906",}

    c.on('ready',function () {
        c.get('foo.txt',function (err,stream) {
            if (err) throw err;
            stream.once('close',function () {
                c.end();
            });
            stream.pipe(fs.createWriteStream('input/foo.local-copy.txt'));
        });
        c.put('foo.txt','foo.remote-copy.txt',function (err) {
            if (err) throw err;
            c.end();
        });
    })

    c.connect(connectionProperties);
});

app.listen(8000);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)