【问题标题】:How to create bashrc script for anonymous upload service file.io?如何为匿名上传服务 file.io 创建 bashrc 脚本?
【发布时间】: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


    【解决方案1】:

    以下对我有用。

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

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

    【讨论】:

    • 哇,非常感谢!对此,我真的非常感激! :) 嘿,你知道我将如何更改到期日期吗?可能永远?再次感谢曼努埃尔!
    • 改成:curl -F "file=@$1" https://file.io/?expires=999y,999年后过期
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-31
    • 2010-10-26
    • 2018-02-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多