Node.js实现ftp文件下载

Node.js实现ftp文件下载

function timing_getlist(ftp_type, path, uuid, time) {
    
    
    console.log('十分钟扫描一次 ( ' + ftp_type + ' )TFP')
    uuid = new Client();
    uuid.connect(config[ftp_type]);
    uuid.list(path, function (err, list) {
    
    
        if (err) throw err;
        list.forEach(function (item) {
    
    
            if (item.type === 'd') {
    
       //类型为文件夹时继续往下走
                if (item.name === '.') return;
                if (item.name === '..') return;
                if ((item.name).indexOf('AQUA') != -1) return;
                if ((item.name).indexOf('AVHRR') != -1) return;
                if ((item.name).indexOf('cma') != -1) return;
                if ((item.name).indexOf('NPP') != -1) return;
                if ((item.name).indexOf('SSR') != -1) return;
                if ((item.name).indexOf('TERRA') != -1) return;
                if (moment(item.date).format('YYYY-MM-DD HH:mm:ss') < time) return;
                getlist(ftp_type, path + '/' + item.name, uuid);//遍历一下这个文件夹
            } else {
    
    
                let picPath = path + '/' + item.name
                // console.log(picPath)
                picPath = picPath.substring(1)
                ld_dao.listdatafindOrCreate(item.name, {
    
        //新增OK文件记录
                    ftp_type: ftp_type,
                    ok_name: item.name,
                    ok_path: picPath,
                    ok_time: moment(item.date).format('YYYY-MM-DD HH:mm:ss'),
                    data_state: 1
                }).then(function (data) {
    
    
                    if (data.add_file) {
    
    
                        console.log('有新增数据')
                    }
                })
                return picPath
            }
        });
    });
}

猜你喜欢

转载自blog.csdn.net/sll714827/article/details/113365678