【发布时间】:2018-12-09 06:49:43
【问题描述】:
我正在尝试为我的 .bashrc 创建一个适用于匿名文件上传服务 file.io 的脚本...
这是我一直在使用的,但这个是为 transfer.sh 服务的:
# anonymous file uploading to transfer.sh via command line ($ upload file.any)
upload() { if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi
tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; }
效果很好!但是下面来自file.io网站的代码对我没有一点帮助。我觉得我已经尝试了所有方法,但到目前为止我并不是最擅长编码的......
curl -F "file=test.txt" https://file.io
{"success":true,"key":"2ojE41","link":"https://file.io/2ojE41","expiry":"14 days"}
我尝试了很多不同的东西,第一个是:(还有很多不同的变体)
upload2 () {
curl -F "file=$1" https://file.io
{"success":true,"key":"2ojE41","link":"https://file.io/2ojE41","expiry":"14 days"}
}
谁能帮我学习?
【问题讨论】:
标签: linux file service upload command