start the feature of replacing an existing image

This commit is contained in:
2024-05-15 08:13:01 -06:00
parent 6cd4a5a988
commit 127244731d
4 changed files with 142 additions and 36 deletions
Executable
+18
View File
@@ -0,0 +1,18 @@
# requires node & curl & jq
HOST=http://localhost:3002
CODE='OWNER_DID="did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F"; OWNER_PRIVATE_KEY_HEX="2b6472c026ec2aa2c4235c994a63868fc9212d18b58f6cbfe861b52e71330f5b"; didJwt = require("did-jwt"); didJwt.createJWT({ exp: Math.floor(Date.now() / 1000) + 60, iat: Math.floor(Date.now() / 1000), iss: OWNER_DID }, { issuer: OWNER_DID, signer: didJwt.SimpleSigner(OWNER_PRIVATE_KEY_HEX) }).then(console.log)'
# exit as soon as anything fails
set -e
JWT=$(node -e "$CODE")
RESULT=$(curl -X POST -H "Authorization: Bearer $JWT" -F "image=@test1.png" $HOST/image)
echo $RESULT
URL=$(echo $RESULT | jq -r '.url')
STATUS_CODE=$(curl -o out-test1.png -w "%{http_code}" $URL);
if [ $STATUS_CODE -ne 200 ]; then
echo "File is not accessible, received status code: $STATUS_CODE";
fi