Add upload-jmespath script for JSON file uploads to API
This commit is contained in:
41
bin/upload-jmespath
Executable file
41
bin/upload-jmespath
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
API_URL="https://jmespath-playground.koszewscy.waw.pl"
|
||||
JSON_FILE="-"
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $0 [--api-url <url>] [--json-file <file>]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--api-url)
|
||||
API_URL="$2"
|
||||
shift 2
|
||||
;;
|
||||
--json-file)
|
||||
JSON_FILE="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: Unknown argument: $1"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Send the POST request
|
||||
curl -s -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Accept: application/json" \
|
||||
--data @${JSON_FILE} \
|
||||
"$API_URL/api/v1/upload"
|
||||
|
||||
Reference in New Issue
Block a user