Skip to main content

files.upload

Upload files from paths visible inside the server container (typically /uploads/...). Place files under ~/.moorcheh/uploads on the host before calling the API.
client.files.upload(
    namespace_name: str,
    *,
    files: list[dict],
) -> dict[str, Any]
API: POST /namespaces/{namespace_name}/files — see Upload file

Examples

from pathlib import Path
from moorcheh import MoorchehClient
from moorcheh.docker_runtime import ensure_upload_dir, host_path_to_container_upload_path

with MoorchehClient("http://localhost:8080") as client:
    upload_root = ensure_upload_dir()
    host_file = (upload_root / "document.pdf").resolve()
    container_path = host_path_to_container_upload_path(host_file, upload_root)

    resp = client.files.upload(
        "my-documents",
        files=[
            {"path": container_path, "department": "engineering", "force_reindex": False}
        ],
    )
    job_id = resp["job_id"]

    while True:
        job = client.files.job_status("my-documents", job_id)
        if job["status"] in ("completed", "failed"):
            break