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