#文件传输 #发送文件 #axum #发送接收 #API #IP地址 #网络

app swift_file

使用Wi-Fi网络在设备之间发送或接收文件

8个版本

0.1.9 2023年11月29日
0.1.8 2023年11月21日
0.1.7 2023年7月9日
0.1.6 2023年5月17日
0.1.5 2023年4月30日

#2 in #发送文件

MIT许可证

255KB
643

swift_file

使用QR码在Wi-Fi网络上传输文件的Rust实现。此工具受claudiodangelis/qrcp的启发。

它如何工作?

sf服务器绑定到服务器所在机器的默认网络接口的IP地址。或者,用户可以选择IP地址(--port)、特定的网络接口(--interface)和端口(--port)。

打印的二维码编码了一个http URL,通常格式如下

http://{ip}:{port}/{download|receive}/[可选后缀]

已知限制

  • 一些iOS浏览器无法下载文件。它始终与Safari一起工作,但与Brave一起失败。其他基于Chromium的iOS浏览器也可能出现下载失败的情况。

安全性

此crate使用#![forbid(unsafe_code)]来确保所有内容都是用100%安全的Rust实现的。

安装选项

使用cargo安装

swift_file已发布在crates.io。要从crates.io安装Rust crate,需要在您的系统上安装Rust和cargo

cargo install swift_file

从存档手动安装

最新版本页面提供了一个选项,可以手动从存档安装sf二进制文件。存档适用于Linux、MacOS和Windows。下载、解压并将二进制文件移动到所需目录,并设置执行权限。

Linux

  1. 从最新发布版下载Linux tar.gz存档
  2. 解压存档
tar xf swift_file_*_x86_64-unknown-linux-musl.tar.gz
  1. 移动二进制文件
sudo mv sf /usr/local/bin
  1. 设置执行权限
sudo chmod +x /usr/local/bin/sf
  1. 运行sf
sf --help

MacOS

  1. 从最新发布版下载MacOS (apple-darwin) ZIP存档
  2. 解压存档
unzip swift_file_*_x86_64-apple-darwin.zip
  1. 移动二进制文件
sudo mv sf /usr/local/bin
  1. 设置执行权限
sudo chmod +x /usr/local/bin/sf
  1. 运行sf
sf --help

Windows

  1. 从最新的发布版下载Windows ZIP存档
  2. 解压存档
  3. 运行sf.exe

CLI用法

Send or receive files between devices using Wi-Fi network

Usage: sf [OPTIONS] <COMMAND>

Commands:
  send     Send a file
  receive  Receive a file
  help     Print this message or the help of the given subcommand(s)

Options:
      --ip <IP>                IP Address to bind to
  -i, --interface <INTERFACE>  Network interface to use (ignored if --ip provided)
  -p, --port <PORT>            Server port
  -h, --help                   Print help
  -V, --version                Print version

向另一台设备发送文件

Send a file

Usage: sf send [OPTIONS] <FILE>

Arguments:
  <FILE>  File path to send

Options:
      --ip <IP>                IP Address to bind to
      --zip                    ZIP file or directory before transferring
  -i, --interface <INTERFACE>  Network interface to use (ignored if --ip provided)
  -p, --port <PORT>            Server port
  -h, --help                   Print help

从另一台设备接收文件

Receive files

Usage: sf receive [OPTIONS]

Options:
  -d, --dest-dir <DEST_DIR>    Destination directory
      --ip <IP>                IP Address to bind to
  -i, --interface <INTERFACE>  Network interface to use (ignored if --ip provided)
      --no-open                Disable opening the received file automatically using the system default program
  -p, --port <PORT>            Server port
  -h, --help                   Print help

依赖项

约14-44MB
约736K SLoC