> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ns.rocks/llms.txt
> Use this file to discover all available pages before exploring further.

# Resumable Upload

> Upload files and directories with progress and retry recovery.

## Setup

```bash theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
uv pip install "${NULLSPACE_SDK_INSTALL_SPEC:-nullspace-sdk==1.0.0}"
export NULLSPACE_API_KEY=ns_live_...
export NULLSPACE_API_URL=https://api.your-nullspace-domain
```

## Python

```python theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
from nullspace import FileUploadError, Machine

def on_progress(event) -> None:
    print(event.phase, event.bytes_completed, event.bytes_total, event.transport)

with Machine.create(template="base", timeout=300) as machine:
    try:
        result = machine.files.upload_file(
            "./dist/model.bin",
            "/workspace/model.bin",
            resumable=True,
            progress=on_progress,
        )
    except FileUploadError as exc:
        if exc.upload_id is None:
            raise
        result = machine.files.resume_upload(
            exc.upload_id,
            "./dist/model.bin",
            progress=on_progress,
        )

    print(result.target_path, result.bytes_uploaded)
```

## Directory upload

```python theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
result = machine.files.upload_dir(
    "./src",
    "/workspace/src",
    ignore_patterns=["*.pyc"],
)
print(result.file_count, result.target_path)
```

Guide: [Uploads](../filesystem/uploads).
