feat: webdav download via httpx mit basic-auth

This commit is contained in:
2026-05-04 22:18:01 +02:00
parent ec55110ae4
commit b5b46e41ad
2 changed files with 65 additions and 0 deletions

21
app/ingest/webdav.py Normal file
View File

@@ -0,0 +1,21 @@
import httpx
class WebDAVError(Exception):
pass
async def download_file(base_url: str, user: str, password: str, file_path: str, *, timeout: float = 60.0) -> bytes:
"""Fetch a file from Nextcloud WebDAV. Returns the raw bytes."""
base = base_url.rstrip("/")
rel = file_path.lstrip("/")
url = f"{base}/{rel}"
async with httpx.AsyncClient(auth=(user, password), timeout=timeout) as client:
response = await client.get(url)
if response.status_code != 200:
raise WebDAVError(
f"WebDAV GET {file_path} failed: status={response.status_code}"
)
return response.content