This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user