:-'Generic Commit'
Some checks failed
Build-Test-Publish / Build (push) Has been cancelled

This commit is contained in:
Your Name
2025-05-30 21:35:19 +12:00
parent a75826e535
commit 66048b3443

View File

@@ -1,5 +1,15 @@
#!/bin/bash
# read ~/.config/simple_object_storage/config.json
CONFIG_PATH="./config.json"
if [ ! -f "${CONFIG_PATH}" ]; then
echo "config file not found at ${CONFIG_PATH}"
exit 1
fi
CONFIG=$(cat "${CONFIG_PATH}")
# Create a temporary test file (1024MB!)
echo "Creating test file..."
dd if=/dev/urandom of=test_file.bin bs=1M count=1024
@@ -9,20 +19,14 @@ echo "Calculating original file hash..."
ORIGINAL_HASH=$(sha256sum test_file.bin | cut -d' ' -f1)
echo "Original hash: $ORIGINAL_HASH"
# read ~/.config/simple_object_storage/config.json
CONFIG_PATH="${HOME}/.config/simple_object_storage/config.json"
if [ ! -f "${CONFIG_PATH}" ]; then
echo "config file not found at ${CONFIG_PATH}"
exit 1
fi
CONFIG=$(cat "${CONFIG_PATH}")
# get the host and port from the config
HOST=$(echo $CONFIG | jq -r '.host')
PORT=$(echo $CONFIG | jq -r '.port')
HOST=$(echo "$CONFIG" | jq -r '.host')
PORT=$(echo "$CONFIG" | jq -r '.port')
# extract the first write token from the config
WRITE_TOKEN=$(echo $CONFIG | jq -r '.write_tokens[0]')
WRITE_TOKEN=$(echo "$CONFIG" | jq -r '.write_tokens[0]')
# Upload the file
echo "Uploading file..."
@@ -34,7 +38,7 @@ RESPONSE=$(curl -X PUT \
echo "Upload response: $RESPONSE"
# Extract the hash from the response
HASH=$(echo $RESPONSE | jq -r '.hash')
HASH=$(echo "$RESPONSE" | jq -r '.hash')
echo "Hash: $HASH"
# Check if the file exists by hash