使用angular 5+从ftp下载文件? [英] Download file from ftp using angular 5+?

查看:81
本文介绍了使用angular 5+从ftp下载文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用名为ftp-client的npm库(

I'm trying to use the npm library called ftp-client (https://www.npmjs.com/package/ftp-client) to download a simple image from my ftp server in my Angular 5 application. I copy-pasted the example but it does not seem to be working, I see this error in the console:

代码是:

var ftpClient = require('../../../../../node_modules/ftp-client'),
config = {
  host: 'ftp://myhost.com',
  port: 21,
  user: 'admin',
  password: 'admin'
},
options = {
    logging: 'basic'
},
client = new ftpClient(config, options);
client.connect(function (){
  client.download('/images/no-img.jpg', 'test/', {
      overwrite: 'all'
  }, function (result) {
      console.log(result);
  });
});

以防万一,ng -v输出为:

Just in case, ng -v output is:

Angular CLI: 1.7.4
Node: 8.11.1
OS: win32 x64
Angular: 5.2.11

您认为这可能是什么?

谢谢!

推荐答案

我认为问题出在打字稿符号上

I think the problem is with typescript notation

您应该使用:

import * as ftpClient from 'ftp-client';

而不是:

var ftpClient = require('../../../../../node_modules/ftp-client'),

这篇关于使用angular 5+从ftp下载文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆