summaryrefslogtreecommitdiff
path: root/local/bin/upim
diff options
context:
space:
mode:
Diffstat (limited to 'local/bin/upim')
-rwxr-xr-xlocal/bin/upim21
1 files changed, 21 insertions, 0 deletions
diff --git a/local/bin/upim b/local/bin/upim
new file mode 100755
index 0000000..cbd07d1
--- /dev/null
+++ b/local/bin/upim
@@ -0,0 +1,21 @@
+#!/usr/bin/env sh
+if [ -z "$1" ]; then
+ echo "usage: $0 <file>"
+ exit 1
+fi
+FILE="$1"
+RESPONSE=$(curl -s -X POST \
+ -F "file=@${FILE}" \
+ https://coast.is-terrible.com/api/files/create)
+URL=$(echo "$RESPONSE" | jq -r '.url')
+THUMBNAIL_URL=$(echo "$RESPONSE" | jq -r '.thumb')
+DELETION_URL=$(echo "$RESPONSE" | jq -r '.del_url')
+ERROR=$(echo "$RESPONSE" | jq -r '.error')
+if [ "$ERROR" != "null" ]; then
+ echo "Error uploading file: $ERROR"
+ exit 1
+fi
+echo "file uploaded successfully!"
+echo "url: $URL"
+echo "thumbnail url: $THUMBNAIL_URL"
+echo "deletion url: $DELETION_URL"