Skip to content

Instantly share code, notes, and snippets.

@miracle2k
Created December 29, 2014 01:07
Show Gist options
  • Save miracle2k/21a6ed83b05af6c3e608 to your computer and use it in GitHub Desktop.
Save miracle2k/21a6ed83b05af6c3e608 to your computer and use it in GitHub Desktop.
Upload to imgur from your headless server
#!/bin/bash
# https://github.com/Ceryn/img
# Call with '-s' to target only a selection of the screen.
clientid='3e7a4deb7ac67da'
img=$1
res=$(curl -sH "Authorization: Client-ID $clientid" -F "image=@$img" "https://api.imgur.com/3/upload")
echo $res
echo $res | grep -qo '"status":200' && link=$(echo $res | sed -e 's/.*"link":"\([^"]*\).*/\1/' -e 's/\\//g')
echo $link
#echo "$res" > "$img.error"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment