This commit is contained in:
pratik
2025-10-22 11:38:43 -05:00
parent b395b310e1
commit 401d53da50

View File

@@ -45,6 +45,9 @@ CF_SKIP_SSL="false" # Use "true" for self-signed certificates
POLL_INTERVAL=5 # seconds between status checks
MAX_WAIT=600 # maximum wait time in seconds (10 minutes)
# Debug mode (set to "true" to see curl commands and responses)
DEBUG_MODE="false"
# Security configuration (optional)
CERT_FILE="" # Path to client certificate file (leave empty to skip)
KEY_FILE="" # Path to client private key file (leave empty to skip)
@@ -147,14 +150,55 @@ echo ""
#############################################################################
log_info "Step 1/5: Initializing upload session..."
INIT_RESPONSE=$(eval curl -s -X POST "$API_BASE/upload/init" \
# Debug mode output
if [ "$DEBUG_MODE" = "true" ]; then
echo "DEBUG: API_BASE = $API_BASE"
echo "DEBUG: CURL_OPTS = $CURL_OPTS"
echo "DEBUG: Request JSON:"
echo "$CF_CONFIG"
fi
# Build the curl command
if [ -n "$CURL_OPTS" ]; then
if [ "$DEBUG_MODE" = "true" ]; then
INIT_RESPONSE=$(eval curl -v -X POST "$API_BASE/upload/init" \
-H "Content-Type: application/json" \
$CURL_OPTS \
-d "'$CF_CONFIG'")
else
INIT_RESPONSE=$(eval curl -s -X POST "$API_BASE/upload/init" \
-H "Content-Type: application/json" \
$CURL_OPTS \
-d "'$CF_CONFIG'")
fi
else
if [ "$DEBUG_MODE" = "true" ]; then
INIT_RESPONSE=$(curl -v -X POST "$API_BASE/upload/init" \
-H "Content-Type: application/json" \
-d "$CF_CONFIG")
else
INIT_RESPONSE=$(curl -s -X POST "$API_BASE/upload/init" \
-H "Content-Type: application/json" \
-d "$CF_CONFIG")
fi
fi
if [ $? -ne 0 ]; then
log_error "Failed to initialize upload session"
CURL_EXIT_CODE=$?
if [ "$DEBUG_MODE" = "true" ]; then
echo "DEBUG: Curl exit code: $CURL_EXIT_CODE"
echo "DEBUG: Response:"
echo "$INIT_RESPONSE"
fi
if [ $CURL_EXIT_CODE -ne 0 ]; then
log_error "Failed to initialize upload session (curl exit code: $CURL_EXIT_CODE)"
echo "$INIT_RESPONSE"
exit 1
fi
# Debug output
if [ -z "$INIT_RESPONSE" ]; then
log_error "Empty response from server"
exit 1
fi