File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -385,8 +385,51 @@ jobs:
385385 local response_file="$4"
386386 shift 4
387387
388+ local status_file
388389 local status_code
389- status_code="$(curl -sS -o "$response_file" -w "%{http_code}" "$@" "$target_url" || true)"
390+ local curl_exit
391+ local curl_pid
392+ local file_size_bytes
393+ local file_size_mb
394+
395+ status_file="${response_file}.status"
396+ file_size_bytes="$(wc -c < "$file_path" | tr -d ' ')"
397+ file_size_mb="$(awk -v size="$file_size_bytes" 'BEGIN { printf "%.2f", size / 1024 / 1024 }')"
398+
399+ echo "Starting upload attempt (${mode}) for $(basename "$file_path") (${file_size_mb} MiB)"
400+
401+ : > "$response_file"
402+ : > "$status_file"
403+
404+ (
405+ curl -sS \
406+ --connect-timeout 30 \
407+ --http1.1 \
408+ -o "$response_file" \
409+ -w "%{http_code}" \
410+ "$@" \
411+ "$target_url" > "$status_file"
412+ ) &
413+ curl_pid=$!
414+
415+ while kill -0 "$curl_pid" 2>/dev/null; do
416+ echo "Upload still running (${mode}) for $(basename "$file_path")..."
417+ sleep 15
418+ done
419+
420+ curl_exit=0
421+ wait "$curl_pid" || curl_exit=$?
422+
423+ status_code="$(cat "$status_file" 2>/dev/null || true)"
424+ rm -f "$status_file"
425+
426+ if [ "$curl_exit" -ne 0 ]; then
427+ echo "Upload attempt exited with curl status ${curl_exit} (${mode})"
428+ if [ -s "$response_file" ]; then
429+ cat "$response_file"
430+ fi
431+ return 1
432+ fi
390433
391434 if [[ "$status_code" =~ ^2[0-9][0-9]$ ]]; then
392435 return 0
@@ -513,6 +556,7 @@ jobs:
513556 "$upload_url" \
514557 "$response_file" \
515558 -X "$request_method" \
559+ -H "Expect:" \
516560 "${extra_header_args[@]}" \
517561 "${binary_payload_args[@]}"; then
518562 echo "Uploaded ${file_name} via ${request_method} binary."
You can’t perform that action at this time.
0 commit comments