1.0.0 • Published 4 years ago

server-file-up-down v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

Table of Contents generated with DocToc

server-file-up-down

目前仅支持 ftp 上传/下载

安装

npm i server-file-up-down

使用

const { FTP } = require("server-file-up-down");

// for example
(async () => {
  // 参数参考 https://github.com/mscdex/node-ftp
  const connectionOptions = {
    host: "192.168.1.11",
    port: 21,
    user: "user",
    password: "password",
    connTimeout: 1000 * 10, // 连接超时时间
    pasvTimeout: 1000 * 0.3, // 每个文件上传间隔时间
    keepalive: 1000 * 10, // 多久发送一次请求,以保持连接
  };
  // 参数参考如下表格
  const options = {
    targetPath: path.resolve(process.cwd(), "dist"),
    excludeExt: ["zip"],
    excludeFolder: ["img"],
    remotePath: "js",
    clean: false,
  };
  const ftp = new Ftp(connectionOptions, options);

  console.log("start");
  // 上传
  // await ftp.upload();
  // 下载
  await ftp.download();
  console.log("over");
})();

参数配置

属性类型默认值必填上传说明下载说明
targetPathstring本地项目根目录下的dist目录上传本地项目根目录dist目录下的所有文件,必须是绝对路径下载至本地的目录,必须是绝对路径
remotePathstring远程根目录远程目录,填写相对路径远程目录,填写相对路径
excludeExtstring | string[]string: 过滤一个后缀(e.g. 'zip'),string[]: 过滤多个后缀(e.g. 'zip','txt')同左
excludeFolderstring | string[]string: 过滤一个目录(e.g. 'folder'),string[]: 过滤多个目录(e.g. 'folder1','folder2')同左
cleanbooleanfalse上传前是否需要清理远程目录
1.0.0

4 years ago