Skip to main content
The Nextcloud resource mounts a WebDAV server (Nextcloud, ownCloud, Hetzner Storage Share, or any generic WebDAV endpoint) at some prefix such as /nc/. Reads are async and streaming, with range requests for partial reads. For credential setup, see Nextcloud Setup.

Config

import os

from mirage import MountMode, Workspace
from mirage.resource.nextcloud import NextcloudConfig, NextcloudResource

config = NextcloudConfig(
    url=os.environ["NEXTCLOUD_URL"],
    username=os.environ["NEXTCLOUD_USERNAME"],
    password=os.environ["NEXTCLOUD_PASSWORD"],
    # Optional:
    # verify_ssl=True,
    # timeout=30,
)
resource = NextcloudResource(config)
ws = Workspace({"/nc/": resource}, mode=MountMode.WRITE)
NextcloudResource(config) takes a NextcloudConfig object with the WebDAV URL plus optional Basic Auth credentials. Both READ and WRITE modes are supported. Use an app password (Settings → Security in Nextcloud) rather than your account password.

Filesystem Layout

WebDAV resources map directly to virtual paths under the mount prefix. For example, if your Nextcloud root contains:
Documents/notes.md
Documents/contract.pdf
Photos/2024/cat.jpg
Then mounting at /nc/ exposes:
/nc/
  Documents/
    notes.md
    contract.pdf
  Photos/
    2024/
      cat.jpg
Path mapping: virtual /nc/Documents/notes.md issues HTTP requests against <NEXTCLOUD_URL>/Documents/notes.md.

Cache

The Nextcloud resource uses IndexCacheStore. Directory listings come from a single PROPFIND Depth: 1 and populate file size, type, and ETag entries that stat reads via a fast path, so a readdir followed by per-entry stat calls (which is what ls, FUSE getattr, and most shell commands trigger) costs one HTTP request instead of N.

Fingerprinting and Snapshots

SUPPORTS_SNAPSHOT = True. Per-file fingerprints come from the WebDAV getetag property, so snapshot drift detection works automatically: when a remote file changes, its ETag changes, and Mirage notices on the next access.

Example

import asyncio
import os

from dotenv import load_dotenv

from mirage import MountMode, Workspace
from mirage.resource.nextcloud import NextcloudConfig, NextcloudResource

load_dotenv(".env.development")

config = NextcloudConfig(
    url=os.environ["NEXTCLOUD_URL"],
    username=os.environ["NEXTCLOUD_USERNAME"],
    password=os.environ["NEXTCLOUD_PASSWORD"],
)
resource = NextcloudResource(config)


async def main() -> None:
    ws = Workspace({"/nc/": resource}, mode=MountMode.WRITE)

    r = await ws.execute("ls /nc/")
    print(await r.stdout_str())

    r = await ws.execute("tree /nc/")
    print(await r.stdout_str())

    r = await ws.execute("find /nc/ -name '*.md'")
    print(await r.stdout_str())

    r = await ws.execute("cat /nc/Documents/notes.md")
    print(await r.stdout_str())

    r = await ws.execute("grep TODO /nc/Documents/notes.md")
    print(await r.stdout_str())

    r = await ws.execute("stat /nc/Documents/notes.md")
    print(await r.stdout_str())


if __name__ == "__main__":
    asyncio.run(main())

Shell Commands

The Nextcloud resource supports the full set of shell commands since it operates on real file content (text, binary, JSON, CSV, etc.). Reads benefit from HTTP Range requests so commands like head -c BYTES don’t pull the whole file.

Read Commands

CommandNotes
catRead file content
head / tailFirst/last N lines
grep / rgPattern search (file or directory level)
jqQuery JSON fields
wcLine/word/byte counts
statFile metadata (name, size, type, modified)
findRecursive search with -name, -maxdepth
treeDirectory tree view
nlNumber lines
duDisk usage summary
fileDetect file type
stringsExtract printable strings from binary
xxdHex dump
md5MD5 checksum
sha256sumSHA-256 checksum

Text Processing

CommandNotes
awkPattern scanning and processing
sedStream editor
trTranslate or delete characters
sortSort lines
uniqRemove duplicate lines
cutExtract fields/columns
joinJoin lines on a common field
pasteMerge lines side by side
columnColumnate output
foldWrap lines to a specified width
expandConvert tabs to spaces
unexpandConvert spaces to tabs
fmtSimple text formatter
revReverse lines
tacConcatenate and print in reverse
lookDisplay lines beginning with a given string
shufShuffle lines
tsortTopological sort
commCompare two sorted files
cmpCompare two files byte by byte
diffCompare files line by line
patchApply a diff patch
iconvCharacter encoding conversion

File Operations

CommandNotes
cpCopy files (WebDAV COPY method)
mvMove/rename files (WebDAV MOVE method)
rmRemove files (WebDAV DELETE; recursive for directories)
mkdirCreate directories (WebDAV MKCOL)
touchCreate empty file or update timestamp
lnCreate symbolic links
teeWrite stdin to file and stdout
mktempCreate temporary file
splitSplit file into pieces
csplitSplit file by context

Path Utilities

CommandNotes
basenameStrip directory from path
dirnameStrip filename from path
realpathResolve path
readlinkPrint symbolic link target
lsList directory contents

Compression

CommandNotes
gzipCompress files
gunzipDecompress gzip files
zipCreate zip archives
unzipExtract zip archives
tarArchive files
zcatCat compressed files
zgrepGrep compressed files

Encoding

CommandNotes
base64Base64 encode/decode

Data Format Support

Commands with format-specific variants for structured data files:
FormatExtensionVariants
Parquet.parquetcat, head, tail, wc, stat, cut, grep, ls, file
Feather.feathercat, head, tail, wc, stat, cut, grep, ls, file
ORC.orccat, head, tail, wc, stat, cut, grep, ls, file
HDF5.hdf5cat, head, tail, wc, stat, cut, grep, ls, file
These variants auto-detect the format by extension and convert to tabular text (CSV) for processing.

Streaming

  • Reads: streamed in chunks. Downstream commands like head -n 1 early-cancel, so you only pay for the first chunk over the wire.
  • Range reads: head -c BYTES and other partial reads issue HTTP Range requests that Nextcloud and most WebDAV servers honor.
  • Writes: buffer the payload before upload. Streaming uploads (Nextcloud’s uploads/ resumable protocol) are a possible future follow-up.

Use Cases

  • AI agents accessing personal cloud storage: Mount Nextcloud so agents can read documents, notes, and structured data on a self-hosted cloud.
  • Self-hosted alternative to Dropbox/Box: Same shell-command surface, with full read+write support.
  • Multi-protocol WebDAV: Works against any RFC 4918-compliant server, not just Nextcloud.
  • FUSE mounting: Expose Nextcloud through a virtual FUSE mount for external tools.