diff --git a/.local/share/scripts/upload-image.sh b/.local/share/scripts/upload-image.sh new file mode 100755 index 0000000..ed1f2b0 --- /dev/null +++ b/.local/share/scripts/upload-image.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh + +set -eo pipefail + +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") + +source $XDG_CONFIG_HOME/imgur.sh # exports: IMGUR_CLIENT_ID and IMGUR_CLIENT_SECRET + +[ -z "$1" ] && read IMAGE_FILE || IMAGE_FILE="$1" +[ -z "$IMAGE_FILE" ] && echo "No file provided" && exit 1 + +curl -X POST -H "Authorization: Client-ID $IMGUR_CLIENT_ID" -F "image=@$IMAGE_FILE" https://api.imgur.com/3/upload 2>/dev/null| jq --raw-output '.data.link' +