u/upload.sh

16 lines
435 B
Bash
Raw Normal View History

2023-04-28 13:19:02 -04:00
#!/usr/bin/env sh
2023-04-28 14:31:51 -04:00
set -eu
2023-04-28 13:19:02 -04:00
path=$1
extension=$(echo "$path" | cut -d'.' -f2)
2023-04-28 14:31:51 -04:00
data=$(curl -F file=@"$path" -H "Authorization: $U_API_KEY" "$U_HOST/api/upload")
2023-04-28 13:19:02 -04:00
image_id=$(echo "$data" | jq -r .id)
image_revocation_key=$(echo "$data" | jq -r .revocation_key)
2023-04-28 14:31:51 -04:00
echo "$image_id $image_revocation_key" >> "$U_REVOCATION_KEY_PATH"
2023-04-28 13:19:02 -04:00
2023-04-28 14:31:51 -04:00
image_url="$U_HOST/i/$image_id.$extension"
2023-04-28 13:19:02 -04:00
echo "$image_url"
echo "$image_url" | xclip -selection clipboard