u/upload.sh

16 lines
440 B
Bash
Raw Normal View History

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