dotfiles-remastered/.local/share/scripts/upload-image.sh

15 lines
451 B
Bash
Executable File

#!/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'