Skip to content

Instantly share code, notes, and snippets.

@aman-roy
Last active December 30, 2019 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aman-roy/b316da442cb4b623285185595c376985 to your computer and use it in GitHub Desktop.
Save aman-roy/b316da442cb4b623285185595c376985 to your computer and use it in GitHub Desktop.
upload files via terminal using file.io API
# Upload file via terminal using file.io
# Author : Aman Roy (https://github.com/aman-roy)
upload () { if [ $# = 1 -o $# = 2 ];then if [ -f "$1" ];then if [ $# = 1 ];then curl -F "file=@$1" https://file.io/ ;else if [[ "$2" =~ ^[1-9]+[wmy]$ ]];then curl -F "file=@$1" https://file.io/\?expires=$2;else echo $'Wrong expiration format.\neg. 1(w/m/y), etc.';fi;fi;else echo "file doesn't exist";fi;else echo $'usage: upload file_name.ext [expiration]\nexpiration format: 1-9(w/m/y) # (w)eeks, m(onths), (y)ear';fi }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment