lander/landerctl

57 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env sh
API_KEY=test
URL=http://localhost:18080
2022-11-21 20:02:33 +00:00
if [ "$1" = g ]; then
curl -is "$URL/$2" |
sed -En 's/^[lL]ocation: (.*)/\1/p'
elif [ "$1" = s ]; then
curl \
-w "${URL}%header{location}" \
-XPOST \
2022-11-21 11:03:16 +00:00
-d "$2" \
-H "X-Api-Key: $API_KEY" \
"$URL/s/$3"
2022-11-16 12:05:09 +00:00
2022-11-21 20:02:33 +00:00
elif [ "$1" = sl ]; then
curl \
-w "${URL}%header{location}" \
2022-11-21 20:02:33 +00:00
-XPOST \
-d "$2" \
-H "X-Api-Key: $API_KEY" \
"$URL/sl/$3"
elif [ "$1" = p ]; then
curl \
-w "${URL}%header{location}" \
2022-11-21 20:02:33 +00:00
-XPOST \
-H "X-Api-Key: $API_KEY" \
--data-binary @"$2" \
"$URL/p/$3"
2022-11-21 15:22:52 +00:00
2022-11-21 20:02:33 +00:00
elif [ "$1" = pl ]; then
curl \
-w "${URL}%header{location}" \
2022-11-21 20:02:33 +00:00
-XPOST \
-H "X-Api-Key: $API_KEY" \
--data-binary @"$2" \
"$URL/pl/$3"
elif [ "$1" = f ]; then
curl \
-w "${URL}%header{location}" \
-XPOST \
-H "X-Api-Key: $API_KEY" \
-H "X-Lander-Content-Type: $(file --mime-type --brief $2)" \
--data-binary @"$2" \
"$URL/f/$3"
2023-11-12 14:00:20 +00:00
elif [ "$1" = d ]; then
curl \
-XDELETE \
-H "X-Api-Key: $API_KEY" \
"$URL/$2"
fi