gpt4 book ai didi

linux - 如何为匿名上传服务 file.io 创建 bashrc 脚本?

转载 作者:太空宇宙 更新时间:2023-11-04 12:04:40 25 4
gpt4 key购买 nike

我正在尝试为我的 .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"}
}

谁能帮我学习一下?

最佳答案

以下对我有用。

upload2(){
curl -F "file=@$1" https://file.io
}

然后就可以使用upload2 Testfile并得到回应:{"success":true,"key":"d8Lobo","link":"https://file.io/d8Lobo","expiry":"14 days"}

关于linux - 如何为匿名上传服务 file.io 创建 bashrc 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51112505/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com