aboutsummaryrefslogtreecommitdiff
path: root/upchud-test.sh
diff options
context:
space:
mode:
authoranon2025-07-05 13:11:35 +0200
committeranon2025-07-05 13:11:35 +0200
commit02814d2803a39a0fb14893e5cf30d35609ee67de (patch)
tree6bd70c1febe2a3b7031a28a5caaa00ee27ea4156 /upchud-test.sh
downloademil-up.chud.cyou-02814d2803a39a0fb14893e5cf30d35609ee67de.tar.xz
emil-up.chud.cyou-02814d2803a39a0fb14893e5cf30d35609ee67de.tar.zst
init
Diffstat (limited to 'upchud-test.sh')
-rwxr-xr-xupchud-test.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/upchud-test.sh b/upchud-test.sh
new file mode 100755
index 0000000..6bf91d3
--- /dev/null
+++ b/upchud-test.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+TCL_SCRIPT="./upchud.tcl"
+TEST_FILE="example.png"
+#TEST_FILE="example.txt"
+TCLSH_CMD="$(command -v tclsh)"
+
+# verify files exist
+if [[ ! -x "$TCL_SCRIPT" ]]; then
+ echo "ERROR: cannot execute $TCL_SCRIPT" >&2
+ exit 1
+fi
+if [[ ! -f "$TEST_FILE" ]]; then
+ echo "ERROR: test file $TEST_FILE not found" >&2
+ exit 1
+fi
+
+CONTENT_LENGTH=$(wc -c < "$TEST_FILE")
+export CONTENT_LENGTH
+
+export HTTP_CONTENT_DISPOSITION="form-data; name=\"file\"; filename=\"$TEST_FILE\""
+
+echo "Uploading '$TEST_FILE' ($CONTENT_LENGTH bytes) to $TCL_SCRIPT"
+OUT_NAME=$("$TCLSH_CMD" "$TCL_SCRIPT" < "$TEST_FILE")
+
+echo "Script response:\n $OUT_NAME"