From a0907a888fbe26668e00f594a977d82809d6b9aa Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Wed, 1 Nov 2023 23:17:43 +0100 Subject: [PATCH] added uploade image script for imgur upload --- .local/share/scripts/upload-image.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 .local/share/scripts/upload-image.sh 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' +