updates
This commit is contained in:
@@ -45,6 +45,9 @@ CF_SKIP_SSL="false" # Use "true" for self-signed certificates
|
|||||||
POLL_INTERVAL=5 # seconds between status checks
|
POLL_INTERVAL=5 # seconds between status checks
|
||||||
MAX_WAIT=600 # maximum wait time in seconds (10 minutes)
|
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)
|
# Security configuration (optional)
|
||||||
CERT_FILE="" # Path to client certificate file (leave empty to skip)
|
CERT_FILE="" # Path to client certificate file (leave empty to skip)
|
||||||
KEY_FILE="" # Path to client private key 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..."
|
log_info "Step 1/5: Initializing upload session..."
|
||||||
|
|
||||||
|
# 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" \
|
INIT_RESPONSE=$(eval curl -s -X POST "$API_BASE/upload/init" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
$CURL_OPTS \
|
$CURL_OPTS \
|
||||||
-d "'$CF_CONFIG'")
|
-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
|
CURL_EXIT_CODE=$?
|
||||||
log_error "Failed to initialize upload session"
|
if [ "$DEBUG_MODE" = "true" ]; then
|
||||||
|
echo "DEBUG: Curl exit code: $CURL_EXIT_CODE"
|
||||||
|
echo "DEBUG: Response:"
|
||||||
echo "$INIT_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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user