diff --git a/scripts/podx-tools.sh b/scripts/podx-tools.sh index 24e5442..c1a22d4 100755 --- a/scripts/podx-tools.sh +++ b/scripts/podx-tools.sh @@ -191,6 +191,40 @@ PY printf '%s' "${__id:-}" } +# --- OWUI file helpers ------------------------------------------------------- + +_owui_file_get() { + # usage: _owui_file_get + local fid="$1" + curl -sS -H "Authorization: Bearer $OPENWEBUI_API_KEY" \ + "$(_owui_url)/api/v1/files/$fid" +} + +_owui_wait_file() { + # usage: _owui_wait_file [timeout_secs] + local fid="$1" + local timeout="${2:-120}" # default 2 minutes + local start now status content_len + start="$(date +%s)" + while :; do + now="$(date +%s)" + if [ $((now - start)) -ge "$timeout" ]; then + return 1 + fi + # Fetch status and content length + read -r status content_len <