npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@leizm/sftt

v1.5.0

Published

简单文件传输工具

Downloads

30

Readme

@leizm/sftt

简单文件传输工具

安装

npm i -g @leizm/sftt

命令行工具使用

启动服务器端

使用方法:

sftt-server --help

  Usage: sftt-server [options]

  Options:

    -V, --version      output the version number
    -i, --ip <ip>      允许的来源IP地址,多个地址通过逗号分隔 (default: 127.0.0.1)
    -p, --port <port>  监听的端口 (default: 12345)
    -h, --host <host>  监听的地址 (default: 0.0.0.0)
    -d, --dir <dir>    文件根目录 (default: .)
    -c, --config <config_file>  指定配置文件
    -h, --help         output usage information

示例:

sftt-server --ip 192.168.1.2,127.0.0.1 --port 12345 --host 0.0.0.0 --dir /data

客户端上传文件

使用方法:

sftt-put --help

  Usage: sftt-put [options]

  Options:

    -V, --version          output the version number
    -f, --file <file>      要上传的文件 (default: )
    -d, --dir <dir>        要上传的目录 (default: )
    -s, --server <server>  远程服务器地址(host:port/path) (default: 127.0.0.1:12345/data)
    -c, --config <config_file>  指定配置文件
    -h, --help             output usage information

示例:

# 上传文件
sftt-put --server 127.0.0.1:12345/dir1 --file test.txt
# 上传整个目录下的所有文件
sftt-put --server 127.0.0.1:12345/dir2 --dir data
# 使用token权限验证
sftt-put --server [email protected]:12345/dir1 --file test.txt

通过 PM2 启动服务器端

新建 sftt-server 配置文件 server.config.json

{
  "ip": "127.0.0.1",
  "port": 12345,
  "host": "0.0.0.0",
  "dir": "./data"
}

新建 PM2 配置文件 sftt-server.pm2.yaml

apps:
  - name: sftt-server
    script: /usr/local/bin/sftt-server
    instances: 1
    exec_mode: fork
    args:
      - "--config"
      - "server.config.json"

说明:

  • script 中的 /usr/local/bin/sftt-serversftt-server 命令的绝对文件路径,可以通过执行 which sftt-server 获得
  • args 部分为相应的命令行参数

然后,执行以下命令即可通过 PM2 启动:

pm2 start sftt-server.pm2.yaml

作为模块嵌入

上传文件

import { putFile, putDir } from "@leizm/sftt";

async function main() {

  // 上传指定文件到服务器
  const {key, md5} = await putFile({
    host: '127.0.0.1',
    port: 12345,
    path: '/',
  }, '/path/to/local/file');

  // 上传指定目录下的多有文件到服务器
  const ret = await putDir({
    host: '127.0.0.1',
    port: 12345,
    path: '/',
  }, '/path/to/local/dir', (type, data) => {
    console.log('进度', type, data);
  });

}

License

MIT License

Copyright (c) 2018 Zongmin Lei <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.