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 并下载文件


基础教程推荐
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 直接将值设置为滑块 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01