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


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

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] 命令行使用 
  1. # 将shell函数添加到.bashrc或.zshrc文件中  
  2. transfer() {  
  3.   if [ $# -eq 0 ]; then  
  4.     echo "No arguments specified."  
  5.     echo "Usage: "  
  6.     echo "  transfer <file|directory> ... | transfer <file_name>"  
  7.     return 1  
  8.   fi  
  9.   if tty -s; then  
  10.     file="$1"  
  11.     file_name=$(basename "$file")  
  12.     if [ ! -e "$file" ]; then  
  13.       echo "$file: No such file or directory"  
  14.       return 1  
  15.     fi  
  16.     if [ -d "$file" ]; then  
  17.       file_name="$file_name.zip"  
  18.       (cd "$file" && zip -r -q - .) | curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null  
  19.     else  
  20.       cat "$file" | curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null  
  21.     fi  
  22.   else  
  23.     file_name="$1"  
  24.     curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null  
  25.   fi  
  26. }  
  27. # 现在可以使用函数来上传文件  
  28. $ transfer hello.txt 
  •  [2] 简单上传文件 - 官方支持界面上传 
  1. # 使用curl命令上传文件  
  2. $ curl --upload-file ./hello.txt https://transfer.sh/hello.txt  
  3. https://transfer.sh/66nb8/hello.txt  
  4. # 上传文件设定最大下载次数和过期时间  
  5. $ curl -H "Max-Downloads: 1" -H "Max-Days: 5" --upload-file ./hello.txt https://transfer.sh/hello.txt  
  6. https://transfer.sh/66nb8/hello.txt  
  7. # 下载文件  
  8. $ curl https://transfer.sh/66nb8/hello.txt -o hello.txt  
  1. # 还支持wget上传文件  
  2. $ wget --method PUT --body-file=/tmp/file.tar https://transfer.sh/file.tar -O - -nv  
  3. # 还支持HTTPie上传文件  
  4. $ http https://transfer.sh/ -vv < /tmp/test.log  
  5. # 还支持PowerShell上传文件  
  6. PS H:\> invoke-webrequest -method put -infile .\file.txt https://transfer.sh/file.txt 
  •  [3] 一次上传多个文件 
  1. # 使用filedata执行文件地址  
  2. $ curl -i -F filedata=@/tmp/hello.txt -F filedata=@/tmp/hello2.txt https://transfer.sh/  
  3. # 将下载合并为zip或tar存档  
  4. $ curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).tar.gz  
  5. $ curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).zip 
  •  [4] 传输前使用加密您的文件 
  1. # 使用gpg加密文件  
  2. $ cat /tmp/hello.txt | gpg -ac -o- | curl -X PUT --upload-file "-" https://transfer.sh/test.txt  
  3. # 下载并解密  
  4. $ curl https://transfer.sh/1lDau/test.txt | gpg -o- > /tmp/hello.txt 
  1. # 使用openssl加密文件  
  2. $ cat /tmp/hello.txt | openssl aes-256-cbc -pbkdf2 -e | curl -X PUT --upload-file "-" https://transfer.sh/test.txt  
  3. # 下载并解密  
  4. $ curl https://transfer.sh/1lDau/test.txt | openssl aes-256-cbc -pbkdf2 -d > /tmp/hello.txt  
  1. # 从keybase导入key  
  2. $ keybase track [them]  
  3. # 加密文件  
  4. $ cat somebackupfile.tar.gz | keybase encrypt [them] | curl --upload-file '-' https://transfer.sh/test.txt  
  5. # 解密下载  
  6. $ curl https://transfer.sh/sqUFi/test.md | keybase decrypt 
  •  [5] 扫描恶意软件 
  1. # 使用Clamav扫描恶意软件或病毒  
  2. $ wget http://www.eicar.org/download/eicar.com  
  3. $ curl -X PUT --upload-file ./eicar.com https://transfer.sh/eicar.com/scan  
  4. # 上传恶意软件到VirusTotal并获得永久链接  
  5. $ curl -X PUT --upload-file nhgbhhj https://transfer.sh/test.txt/virustotal 
  •  [6] 加密传输备份 mysql 数据库 
  1. # 备份+加密+传输  
  2. $ mysqldump --all-databases | gzip | gpg -ac -o- | curl -X PUT --upload-file "-" https://transfer.sh/test.txt 
  •  [7] 发送带有传输链接的电子邮件 
  1. # 传输和发送带有链接的电子邮件  
  2. $ transfer /tmp/hello.txt | mail -s "Hello World" user@yourmaildomain.com 
  •  [8] 传输日志文件 
  1. # grep syslog for pound and transfer  
  2. $ cat /var/log/syslog | grep pound | curl --upload-file - https://transfer.sh/pound.log  

相关内容