From 7c69a159255388b8dc26c4909917301d60775034 Mon Sep 17 00:00:00 2001 From: surtur Date: Sun, 10 May 2020 11:24:42 +0200 Subject: [PATCH] move away from python for jq JSON parser --- bin/b2-ul_me | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/b2-ul_me b/bin/b2-ul_me index 3c0ae54..1c592cb 100644 --- a/bin/b2-ul_me +++ b/bin/b2-ul_me @@ -13,11 +13,11 @@ echo B2_KEY | sha512sum b2_authorize_account=$(curl -s 'https://api.backblazeb2.com/b2api/v2/b2_authorize_account' -u "$B2_KEY_ID:$B2_KEY") echo b2_authorize_account | sha512sum -apiUrl=$(echo $b2_authorize_account | python -c "import sys, json; print (json.load(sys.stdin)['apiUrl'])") -B2_TOKEN=$(echo $b2_authorize_account | python -c "import sys, json; print (json.load(sys.stdin)['authorizationToken'])") -B2_BUCKET_ID=$(echo $b2_authorize_account | python -c "import sys, json; print (json.load(sys.stdin)['bucketId'])") +apiUrl=$(echo $b2_authorize_account | jq -r '.apiUrl') +B2_TOKEN=$(echo $b2_authorize_account | jq -r '.authorizationToken') +B2_BUCKET_ID=$(echo $b2_authorize_account | jq -r 'bucketId') -UPLOAD_URL=$(curl -s -H "Authorization:$B2_TOKEN" -d '{"bucketId":"$B2_BUCKET_ID"}' $apiUrl/b2api/v2/b2_get_upload_url | python -c "import sys, json; print (json.load(sys.stdin)['uploadUrl'])") +UPLOAD_URL=$(curl -s -H "Authorization:$B2_TOKEN" -d '{"bucketId":"$B2_BUCKET_ID"}' $apiUrl/b2api/v2/b2_get_upload_url | jq -r 'uploadUrl') curl -s -H "Authorization:$B2_TOKEN" -H "X-Bz-File-Name:$FILE_TO_UPLOAD" -H "Content-Type:$MIME_TYPE" -H "X-Bz-Content-Sha1:$SHA1_OF_FILE" -H "X-Bz-Info-Author:${DRONE_COMMIT_AUTHOR}" --data-binary "@$FILE_TO_UPLOAD" $UPLOAD_URL