Skip to content

Instantly share code, notes, and snippets.

@hugomaiavieira
Forked from passalini/upload_to_upl_io.sh
Last active October 15, 2024 17:58
Show Gist options
  • Save hugomaiavieira/255468d778c427b6ff35 to your computer and use it in GitHub Desktop.
Save hugomaiavieira/255468d778c427b6ff35 to your computer and use it in GitHub Desktop.
Upload files to upl.io through command line
# This command receives a file as param, upload it to upl.io and copy the url to
# the clipboard
#
# Dependencies: curl and xclip
#
# Install: copy this code to your .bashrc or .zshrc
#
# Example:
#
# $ upload_file ~/Images/algorich-logo.png
# Uploading...
# http://upl.io/mgun63
#
upl() {
local url
local curl_response
echo 'Uploading...'
url=`curl http://upl.io -F file=@$1 -s -f`
curl_response=$?
echo -n $url | xclip -selection c
echo $url
if [[ "$curl_response" = '0' ]] && [[ "$2" = '-d' ]]; then
rm $1
fi
}
@gingerbeardman
Copy link

gingerbeardman commented Oct 15, 2024

I notice they no longer allow anonymous uploads.

Is there a way to specify api user key on the command line?

edit: figured it out

get your $UPLIO_KEY from the Dashboard after logging in

curl -s -F file=@$1 -F key=$UPLIO_KEY https://upl.io

or

curl -X POST https://upl.io \
  -H "Content-Type: multipart/form-data" \
  -F "file=@$1" \
  -F "key=$UPLIO_KEY"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment