This commit is contained in:
@@ -1,5 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/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!)
|
# Create a temporary test file (1024MB!)
|
||||||
echo "Creating test file..."
|
echo "Creating test file..."
|
||||||
dd if=/dev/urandom of=test_file.bin bs=1M count=1024
|
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)
|
ORIGINAL_HASH=$(sha256sum test_file.bin | cut -d' ' -f1)
|
||||||
echo "Original hash: $ORIGINAL_HASH"
|
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
|
# get the host and port from the config
|
||||||
HOST=$(echo $CONFIG | jq -r '.host')
|
HOST=$(echo "$CONFIG" | jq -r '.host')
|
||||||
PORT=$(echo $CONFIG | jq -r '.port')
|
PORT=$(echo "$CONFIG" | jq -r '.port')
|
||||||
|
|
||||||
# extract the first write token from the config
|
# 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
|
# Upload the file
|
||||||
echo "Uploading file..."
|
echo "Uploading file..."
|
||||||
@@ -34,7 +38,7 @@ RESPONSE=$(curl -X PUT \
|
|||||||
echo "Upload response: $RESPONSE"
|
echo "Upload response: $RESPONSE"
|
||||||
|
|
||||||
# Extract the hash from the response
|
# Extract the hash from the response
|
||||||
HASH=$(echo $RESPONSE | jq -r '.hash')
|
HASH=$(echo "$RESPONSE" | jq -r '.hash')
|
||||||
echo "Hash: $HASH"
|
echo "Hash: $HASH"
|
||||||
|
|
||||||
# Check if the file exists by hash
|
# Check if the file exists by hash
|
||||||
|
Reference in New Issue
Block a user