推荐一款 GitHub 星标 11.5K 的命令行文件传输神器(开源免费,支持 10GB 大文件)...

公众号关注 「奇妙的 Linux 世界」

设为「星标」,每天带你玩转 Linux !



互联网行业跳槽指南公布,你认可这个顺序吗?

在工作和生活中,我们经常需要在不同设备之间传输文件,但往往会遇到需要安装第三方软件、文件大小限制、传输速度慢等问题。安装第三方软件还好,但是限制传输速度和文件大小就非常恶心了,用着用着就得逼得你充值付费了。不然紧急需要传输一个东西,就非常花费时间和精力了。

1软件介绍

Easy and fast file sharing from the command-line.

当然,我们可以也使用,老牌的 百度云盘(非会员限速)、Dropbox(速度非常之慢)和 Google Drive(需要科学上网),新进的 阿里云盘(虽然不限速但上传不能加速)、奶牛快传(有文件大小总量限制)。但是这里我们要介绍的是一个基于命令行的文件传输工具 —— transfer.sh

  • Made for use with shell

  • Share files with a URL

  • For free

  • Upload up to 10 GB

  • Files stored for 14 days

  • Encrypt your files

  • Maximize amount of downloads

2使用方式

Sample use cases

  • [1] 命令行使用

# 将shell函数添加到.bashrc或.zshrc文件中
transfer() {
  if [ $# -eq 0 ]; then
    echo "No arguments specified."
    echo "Usage: "
    echo "  transfer <file|directory> ... | transfer <file_name>"
    return 1
  fi

  if tty -s; then
    file="$1"
    file_name=$(basename "$file")

    if [ ! -e "$file" ]; then
      echo "$file: No such file or directory"
      return 1
    fi

    if [ -d "$file" ]; then
      file_name="$file_name.zip"
      (cd "$file" && zip -r -q - .) | curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null
    else
      cat "$file" | curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null
    fi

  else
    file_name="$1"
    curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null
  fi
}

# 现在可以使用函数来上传文件
$ transfer hello.txt
  • [2] 简单上传文件 - 官方支持界面上传

# 使用curl命令上传文件
$ curl --upload-file ./hello.txt https://transfer.sh/hello.txt
https://transfer.sh/66nb8/hello.txt

# 上传文件设定最大下载次数和过期时间
$ curl -H "Max-Downloads: 1" -H "Max-Days: 5" --upload-file ./hello.txt https://transfer.sh/hello.txt
https://transfer.sh/66nb8/hello.txt

# 下载文件
$ curl https://transfer.sh/66nb8/hello.txt -o hello.txt
# 还支持wget上传文件
$ wget --method PUT --body-file=/tmp/file.tar https://transfer.sh/file.tar -O - -nv

# 还支持HTTPie上传文件
$ http https://transfer.sh/ -vv < /tmp/test.log

# 还支持PowerShell上传文件
PS H:\> invoke-webrequest -method put -infile .\file.txt https://transfer.sh/file.txt
  • [3] 一次上传多个文件

# 使用filedata执行文件地址
$ curl -i -F filedata=@/tmp/hello.txt -F filedata=@/tmp/hello2.txt https://transfer.sh/

# 将下载合并为zip或tar存档
$ curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).tar.gz
$ curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).zip
  • [4] 传输前使用加密您的文件

# 使用gpg加密文件
$ cat /tmp/hello.txt | gpg -ac -o- | curl -X PUT --upload-file "-" https://transfer.sh/test.txt

# 下载并解密
$ curl https://transfer.sh/1lDau/test.txt | gpg -o- > /tmp/hello.txt
# 使用openssl加密文件
$ cat /tmp/hello.txt | openssl aes-256-cbc -pbkdf2 -e | curl -X PUT --upload-file "-" https://transfer.sh/test.txt

# 下载并解密
$ curl https://transfer.sh/1lDau/test.txt | openssl aes-256-cbc -pbkdf2 -d > /tmp/hello.txt
# 从keybase导入key
$ keybase track [them]

# 加密文件
$ cat somebackupfile.tar.gz | keybase encrypt [them] | curl --upload-file '-' https://transfer.sh/test.txt

# 解密下载
$ curl https://transfer.sh/sqUFi/test.md | keybase decrypt
  • [5] 扫描恶意软件

# 使用Clamav扫描恶意软件或病毒
$ wget http://www.eicar.org/download/eicar.com
$ curl -X PUT --upload-file ./eicar.com https://transfer.sh/eicar.com/scan

# 上传恶意软件到VirusTotal并获得永久链接
$ curl -X PUT --upload-file nhgbhhj https://transfer.sh/test.txt/virustotal
  • [6] 加密传输备份 mysql 数据库

# 备份+加密+传输
$ mysqldump --all-databases | gzip | gpg -ac -o- | curl -X PUT --upload-file "-" https://transfer.sh/test.txt
  • [7] 发送带有传输链接的电子邮件

# 传输和发送带有链接的电子邮件
$ transfer /tmp/hello.txt | mail -s "Hello World" user@yourmaildomain.com
  • [8] 传输日志文件

# grep syslog for pound and transfer
$ cat /var/log/syslog | grep pound | curl --upload-file - https://transfer.sh/pound.log

3参考链接

  • transfer.sh 官方网站

  • transfer.sh 的 Github 仓库地址

本文转载自:「 Escape 的博客 」,原文:https://tinyurl.com/5chzpk9w ,版权归原作者所有。欢迎投稿,投稿邮箱: editor@hi-linux.com。


你可能还喜欢

点击下方图片即可阅读

微软开源自有云服务器专属 Linux 发行版 CBL-Mariner,可在 GitHub 免费下载!


『美团|饿了么』外卖红包天天免费领,吃饭省钱杠杠滴!

更多有趣的互联网新鲜事,关注「奇妙的互联网」视频号全了解!

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值