AgentSkillsCN

webdav-client

通过 Python 管理 WebDAV 服务器上的文件,将本地资源上传至 NAS,并实现目录同步。当用户希望将文件上传至 NAS、访问 WebDAV 存储,或通过 WebDAV 管理远程文件时,可使用此功能。

SKILL.md
--- frontmatter
name: webdav-client
description: Manage files on WebDAV servers, upload local resources to NAS, and sync directories using Python. Use when the user wants to upload files to a NAS, access WebDAV storage, or manage remote files via WebDAV.

WebDAV Client

Quick Start

Use this skill to interact with WebDAV servers (like NAS) using Python.

Dependencies

This skill requires webdavclient3:

bash
pip install webdavclient3

Usage

1. Upload Script

Use the included utility script for quick uploads:

bash
python ~/.cursor/skills/webdav-client/scripts/nas_upload.py \
  --host "http://NAS_IP:5005" \
  --user "username" \
  --password "password" \
  --src "./local_file.txt" \
  --dest "/remote/path/file.txt"

2. Python Usage

To integrate into other scripts:

python
from webdav3.client import Client

options = {
 'webdav_hostname': "http://NAS_IP:5005",
 'webdav_login':    "user",
 'webdav_password': "password"
}
client = Client(options)

# Upload
client.upload_sync(remote_path="remote/file.txt", local_path="local/file.txt")

# Download
client.download_sync(remote_path="remote/file.txt", local_path="local/file.txt")

# List
files = client.list("remote_dir")

Common Issues

  • 401 Unauthorized: Check credentials.
  • 404 Not Found: Ensure parent directories exist on remote.
  • Certificate Errors: If using HTTPS with self-signed certs, verify SSL settings.