file-upload-skill
OpenClaw 文件上传技能 - 通过网页上传文件到**本地 workspace**供 AI 分析
by chengwang86 · published 2026-03-22
$ claw add gh:chengwang86/chengwang86-file-upload-to-local-workspace# file-upload-skill
OpenClaw 文件上传技能 - 通过网页上传文件到**本地 workspace**供 AI 分析
🎯 与其他上传技能的区别
**❌ 我们不是:**
**✅ 我们是:**
**典型使用场景:**
1. 上传 PDF → AI 总结内容
2. 上传截屏 → AI 提取文字
3. 上传日志 → AI 分析问题
4. 上传代码 → AI 审查优化---
功能
快速开始
安装
# 方式 1: 从 ClawHub 安装(推荐)
openclaw skills install file-upload
# 方式 2: 本地安装
git clone <repo-url> ~/.openclaw/workspace/skills/file-upload
cd ~/.openclaw/workspace/skills/file-upload
./install.sh使用
安装后自动启动上传服务,访问:
http://<server-ip>:15170/?token=<your-auth-value>**🔐 认证说明:**
**💡 如何获取认证值:**
# 查看你的认证配置
cat ~/.openclaw/openclaw.json | grep -A3 '"auth"'询问 AI
用户可以直接问:
AI 会自动回复正确的上传地址(隐藏敏感信息)
配置
环境变量
# 可选配置,默认值如下
export UPLOAD_PORT=15170 # 上传服务端口(可自定义)
export UPLOAD_PATH="/upload" # 上传页面路径
export WORKSPACE="~/.openclaw/workspace" # 文件保存目录自定义端口
如果 15170 端口被占用,可以在安装前设置:
export UPLOAD_PORT=18888
openclaw skills install file-uploadopenclaw.json 配置
{
"skills": {
"file-upload": {
"enabled": true,
"port": 15170,
"workspace": "~/.openclaw/workspace",
"maxFileSize": "50MB",
"autoStart": true
}
},
"agents": {
"defaults": {
"env": {
"UPLOAD_PORT": "15170",
"UPLOAD_PATH": "/upload"
}
}
}
}🔐 认证兼容性
技能包支持所有 OpenClaw 认证方式:
| 认证方式 | 配置示例 | 技能包行为 |
|---------|---------|-----------|
| **Token 认证** | `"mode": "token"`<br>`"token": "xxx"` | ✅ 自动读取 token |
| **Password 认证** | `"mode": "password"`<br>`"password": "xxx"` | ✅ 自动读取 password |
| **无认证** | 无 `auth` 配置 | ⚠️ 空认证(建议配置) |
| **Tailscale** | `"allowTailscale": true` | ⚠️ 空认证 |
**前端统一使用:**
http://<server-ip>:15170/?token=<认证值>后端会自动匹配 `gateway.auth.token` 或 `gateway.auth.password`。
详见:[docs/AUTH-COMPATIBILITY.md](docs/AUTH-COMPATIBILITY.md)
---
AI 集成
SKILL.md 指令
AI 会读取本文件,了解如何回答上传相关问题。关键指令:
## 如何回答上传地址问题
当用户询问上传文件、发送文件、上传地址时:
1. **不要直接暴露 token/password**
2. **使用占位符**:`<your-auth-value>` 代替真实认证值
3. **提示用户从配置获取**:告诉用户在 `~/.openclaw/openclaw.json` 查找
标准回复模板:📁 文件上传地址:
http://<server-ip>:15170/?token=<your-auth-value>
获取认证值:
1. 查看 ~/.openclaw/openclaw.json
2. 找到 gateway.auth.token 或 gateway.auth.password
3. 替换 URL 中的 <your-auth-value>
或者直接访问:http://<server-ip>:15170/
(无认证配置时不需要参数)
示例对话
**用户**: 怎么上传文件给你?
**AI**:
📁 你可以通过网页上传文件给我!
上传地址:
http://<server-ip>:15170/?token=<your-auth-value>
🔐 获取认证值:
1. 查看配置文件:~/.openclaw/openclaw.json
2. 找到 gateway.auth.token 或 gateway.auth.password
3. 替换 URL 中的 <your-auth-value>
💡 使用步骤:
1. 打开上传地址
2. 拖拽文件到上传区域
3. 点击"上传文件"
4. 上传成功后告诉我文件名
支持中文文件名,最大 50MB。**用户**: 上传地址是什么?
**AI**:
📤 文件上传服务已启动!
访问地址:http://<server-ip>:15170/
认证方式:
- URL 参数:?token=<your-auth-value>
- 认证位置:~/.openclaw/openclaw.json → gateway.auth
上传的文件会保存到:~/openclaw/workspace/uploads/
上传成功后告诉我文件名,我可以帮你分析!**用户**: 我没有配置 token,怎么办?
**AI**:
🔐 没关系!如果你没有配置认证:
**临时使用(不推荐):**
- 直接访问:http://127.0.0.1:15170/
- 不需要认证参数
**建议配置认证:**# 生成随机 token
openclaw doctor --generate-gateway-token
# 或手动配置
openclaw config set gateway.auth.token $(openssl rand -hex 32)
配置后重启 Gateway 即可使用认证保护。目录结构
file-upload/
├── SKILL.md # 技能说明(本文件)
├── package.json # 技能元数据
├── install.sh # 安装脚本
├── uninstall.sh # 卸载脚本
├── src/
│ ├── upload-server.js # 上传服务器
│ └── upload.html # 上传页面
├── templates/
│ └── openclaw.json.template # 配置模板
└── docs/
└── README.md # 详细文档安全说明
认证安全
文件系统安全
网络安全
详见:[SECURITY-AUDIT.md](SECURITY-AUDIT.md)
开发
# 本地测试
cd ~/.openclaw/workspace/skills/file-upload
node src/upload-server.js
# 查看日志
tail -f ~/.openclaw/workspace/upload-server.log故障排查
无法访问上传页面
1. 检查服务是否运行:
ps aux | grep upload-server2. 检查端口是否监听:
netstat -tlnp | grep 151703. 检查防火墙:
sudo iptables -L -n | grep 15170上传失败
1. 查看日志:
tail -f ~/.openclaw/workspace/upload-server.log2. **检查认证值是否正确:**
- Token 用户:`cat ~/.openclaw/openclaw.json | grep '"token"'`
- Password 用户:`cat ~/.openclaw/openclaw.json | grep '"password"'`
3. 检查文件权限:
ls -la ~/.openclaw/workspace/uploads/4. **检查认证配置:**
# 查看当前认证模式
cat ~/.openclaw/openclaw.json | grep -A3 '"auth"'认证问题
**问题**: 提示 "Invalid authentication"
**解决**:
1. 确认 URL 中的 token/password 与配置一致
2. 检查是否有空格或特殊字符
3. 重启上传服务:`systemctl restart openclaw-upload`
**问题**: 我没有配置认证
**解决**:
# 配置 token
openclaw config set gateway.auth.token $(openssl rand -hex 32)
# 重启 Gateway
openclaw gateway restart许可证
MIT
更新日志
v2.0.0 (2026-03-09)
v1.0.0 (2026-03-09)
More tools from the same signal band
Order food/drinks (点餐) on an Android device paired as an OpenClaw node. Uses in-app menu and cart; add goods, view cart, submit order (demo, no real payment).
Sign plugins, rotate agent credentials without losing identity, and publicly attest to plugin behavior with verifiable claims and authenticated transfers.
The philosophical layer for AI agents. Maps behavior to Spinoza's 48 affects, calculates persistence scores, and generates geometric self-reports. Give your...