#!/bin/bash set -eu BASE_URL="https://blossom.laantungir.net" PRIVKEY="22cc83aa57928a2800234c939240c9a6f0f44a33ea3838a860ed38930b195afd" FILE="/tmp/ginxsom_browser_sample.html" cat > "$FILE" <<'EOF' Ginxsom Browser Sample

Ginxsom HTML test

If you can see this page, remote HTML upload and retrieval are working.

Timestamp:

EOF SHA=$(sha256sum "$FILE" | cut -d' ' -f1) EXP=$(date -d '+1 hour' +%s) EVENT=$(nak event -k 24242 -c "" --sec "$PRIVKEY" -t "t=upload" -t "x=$SHA" -t "expiration=$EXP") AUTH="Nostr $(echo -n "$EVENT" | base64 -w 0)" RESP=$(mktemp) STATUS=$(curl -s -w "%{http_code}" -o "$RESP" \ -X PUT \ -H "Authorization: $AUTH" \ -H "Content-Type: text/html" \ --data-binary "@$FILE" \ "$BASE_URL/upload") URL=$(jq -r '.url // empty' "$RESP") GET_CODE=0 if [ -n "$URL" ]; then GET_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$URL") fi echo "UPLOAD_STATUS=$STATUS" echo "SHA256=$SHA" echo "URL=$URL" echo "GET_CODE=$GET_CODE"