HTTP_RESPONSE=$(curl -s -w "API_HTTP_STATUS_CODE:%{http_code}" -X PUT "${url}" -H "Authorization: ${BEARER_TOKEN}" -H "file-name: ${filename}" -H 'Content-type: application/javascript' -d "@./dist/xxxx.js")
# extract the body
HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/API_HTTP_STATUS_CODE\:.*//g')
# extract the status
HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*API_HTTP_STATUS_CODE://')
if [ ! $HTTP_STATUS -eq 200 ]; then
echo "Error [HTTP status: $HTTP_STATUS]"
echo "[HTTP RESPONSE body: $HTTP_BODY]"
exit 1
fi
echo ${HTTP_BODY} | jq .