Skip to content

Instantly share code, notes, and snippets.

@cristihainic
Last active January 2, 2018 10:32
Show Gist options
  • Save cristihainic/69052db0dd5fc128cb7cb24257ea6890 to your computer and use it in GitHub Desktop.
Save cristihainic/69052db0dd5fc128cb7cb24257ea6890 to your computer and use it in GitHub Desktop.
Simple imgur image uploader via link or from local disk. Returns the link of the uploaded image.
#!/bin/bash
if [[ $1 == http* ]];
then
image=$1;
else
image=$(base64 $1);
fi
echo "Your uploaded image URL is:"
curl --request POST \
--url https://api.imgur.com/3/image \
--header 'authorization: Client-ID <INSERT_CLIENT_ID_HERE>' \ # get yours from https://api.imgur.com/oauth2/addclient
--data-binary "image=$image" \
--data "type=binary" | jq '.data.link'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment