correctly parse the JSON

This commit is contained in:
surtur 2020-05-10 19:36:31 +02:00
parent 7c69a15925
commit 2a4cc56334
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

@ -8,16 +8,13 @@ B2_KEY_ID=${3}
B2_KEY=${4}
SHA1_OF_FILE=$(openssl dgst -sha1 $FILE_TO_UPLOAD | awk '{print $2;}')
echo B2_KEY_ID | sha512sum
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 | jq -r '.apiUrl')
B2_TOKEN=$(echo $b2_authorize_account | jq -r '.authorizationToken')
B2_BUCKET_ID=$(echo $b2_authorize_account | jq -r 'bucketId')
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 | jq -r '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