Node.js connect to ftp and download files(Node.js 连接到 ftp 并下载文件)
问题描述
您好,我下载了这个 npm 模块来连接我的 ftp: node-ftps
Hello i downloaded this npm module to connect to my ftp : node-ftps
连接类
var FTPS = require('ftps');
var ftps = new FTPS({
host: 'myhost',
username: 'user',
password: 'mypw',
protocol: 'ftp'
});
ftps.exec(function (err, res) {
console.log();
});
如何检查连接是否成功以及如何从路径中获取所有文件!
how can i check if the connection was successful and how can i get all files from my path!
尝试添加文件,但出现错误,我什至不知道我是否已连接
tryed to add an file but get an error i didn't even know if im connected
推荐答案
我建议你试试 node-ftp
也支持 ftps
,虽然 node-ftps
做同样的工作,它缺乏好的文档和示例.
I would advice you to try node-ftp
which supports ftps
too, Although node-ftps
does the same work, it lacks good documentation and examples.
在这里结帐,
https://github.com/mscdex/node-ftp
要建立连接并访问它的功能,您需要做的就是下载一个名为 ftp-client
的节点包装器,它是专门为 node-ftp
模块.
To setup a connection and to access it features, All you need to do is to download a node wrapper called ftp-client
which is developed exclusively for the node-ftp
module.
您可以通过发出以下命令来安装此包装器,
You can install this wrapper by issuing the below command,
npm install ftp-client
要初始化它,请使用以下命令,
To initialize it use the below command,
var ftpClient = require('ftp-client'),
client = new ftpClient(config, options);
您可以在此处找到完整的示例代码,它将引导您了解我们如何连接到服务器,同时上传 test
目录中的所有文件,仅覆盖服务器上找到的旧文件, 并从 /public_html/test 目录
下载文件.
And you can find a complete example code here which will walk you through how we can connect to a server, and simultaneously upload all files from the test
directory, overwriting only older files found on the server, and download files from /public_html/test directory
.
https://github.com/noodny/node-ftp-client#examples
希望这会有所帮助!
这篇关于Node.js 连接到 ftp 并下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Node.js 连接到 ftp 并下载文件


基础教程推荐
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01