1.0.7 • Published 4 years ago

server-upload-down v1.0.7

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

Table of Contents generated with DocToc

server-upload-down

目前仅支持 ftp 上传/下载

安装

npm i server-upload-down

使用

const { FTP } = require("server-upload-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,
    cleanExcludeExt: "",
    cleanExcludeFolder: "",
    cleanExcludeFiles: "",
  };
  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上传前是否需要清理远程目录
cleanExcludeExtstring | string[]false清理远程目录,排除后缀,格式同参数excludeExt
cleanExcludeFolderstring | string[]false清理远程目录,排除文件夹,格式同参数excludeFolder
cleanExcludeFilesstring | string[]false清理远程目录,指定排除的文件名,string: 过滤一个文件(e.g. 'test.txt'),string[]: 过滤多个文件(e.g. 'test1.txt','test2.txt')
1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago