Added check that prevents throwing a JSON parsing error when the server is down
@@ -30,6 +30,14 @@ EOF
upload() {
RESPONSE="$(curl -F "token={{ token }}" -F "upload=@${1}" {{ upload_url }})";
+
+ if jq -e . >/dev/null 2>&1 <<<"$RESPONSE"; then
+ # Response is JSON
+ echo;
+ else
+ notify-send "Error: Uploading returned unexpected response" "Response: ${RESPONSE}";
+ exit 1;
+ fi
if [[ "$(echo "${RESPONSE}" | jq -r '.message')" == "OK." ]]; then
URL="$(echo "${RESPONSE}" | jq -r '.url')";