qwen_agent/WEBDAV_GUIDE.md
2025-11-07 14:06:54 +08:00

97 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# WebDAV 文件管理服务
您的项目现在已经成功集成了 WebDAV 文件管理服务,替代了原来功能单一的 `/api/v1/projects/tree``/api/v1/projects/subtree` 接口。
## 功能特性
- ✅ 完整的文件/文件夹操作(增删改查、移动、重命名)
- ✅ 支持大文件上传/下载
- ✅ 支持文件夹批量操作
- ✅ 可挂载为网络驱动器
- ✅ 支持任何WebDAV客户端
## 访问方式
### 1. 浏览器访问
直接在浏览器中打开:
```
http://localhost:8001/webdav
```
### 2. 系统挂载
#### Windows
1. 打开 "此电脑"
2. 右键点击 "网络位置" → "添加一个网络位置"
3. 输入:`http://localhost:8001/webdav`
4. 完成,即可在网络驱动器中访问
#### macOS
1. 打开 "访达"
2. 前往 → 连接服务器Cmd+K
3. 输入:`http://localhost:8001/webdav`
4. 连接
#### Linux
使用 davfs2 挂载:
```bash
sudo mount -t davfs http://localhost:8001/webdav /mnt/webdav
```
### 3. 移动端App
使用任何WebDAV客户端App
- iOS: Documents by Readdle, WebDAV Navigator
- Android: Solid Explorer, WebDAV Client
## API 操作示例
### 查看目录列表
```bash
curl -X PROPFIND http://localhost:8001/webdav/
```
### 上传文件
```bash
curl -X PUT http://localhost:8001/webdav/test.txt -d "Hello World"
```
### 下载文件
```bash
curl http://localhost:8001/webdav/test.txt
```
### 创建文件夹
```bash
curl -X MKCOL http://localhost:8001/webdav/new_folder
```
### 删除文件
```bash
curl -X DELETE http://localhost:8001/webdav/test.txt
```
### 移动文件
```bash
curl -X MOVE http://localhost:8001/webdav/test.txt -H "Destination: /webdav/backup/test.txt"
```
## 安全说明
当前配置为开发环境,无需认证即可访问。在生产环境中,建议:
1. 启用HTTPS
2. 配置用户认证
3. 限制访问权限
## 支持的文件操作
| 操作 | HTTP方法 | 说明 |
|------|----------|------|
| 读取文件/目录 | PROPFIND | 获取文件信息和目录列表 |
| 创建文件 | PUT | 上传或更新文件 |
| 创建目录 | MKCOL | 创建新文件夹 |
| 删除文件/目录 | DELETE | 删除文件或空目录 |
| 移动/重命名 | MOVE | 移动或重命名文件/目录 |
| 复制 | COPY | 复制文件/目录 |
现在您可以使用任何支持WebDAV的工具来管理您的 `projects` 文件夹,享受完整的文件管理功能!