Files
openclaw-skill-qiniu/README_SOLUTION.md
daoqi 1aeae9cc51 initial: 七牛云上传 OpenClaw Skill
功能特性:
- 支持 /upload, /u 命令上传文件到七牛云
- 支持 /qiniu-config 配置管理
- 支持飞书卡片交互
- 支持指定上传路径和存储桶
- 自动刷新 CDN 缓存
- 支持文件覆盖上传

包含组件:
- OpenClaw 处理器 (openclaw-processor.js)
- 独立监听器 (scripts/feishu-listener.js)
- 核心上传脚本 (scripts/upload-to-qiniu.js)
- 部署脚本 (deploy.sh)
- 完整文档

部署方式:
1. 复制 skill 到 ~/.openclaw/workspace/skills/
2. 配置 ~/.openclaw/credentials/qiniu-config.json
3. 重启 OpenClaw Gateway
2026-03-07 16:02:18 +08:00

140 lines
3.4 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.
# 七牛云覆盖上传问题 - 最终解决方案
## 🔍 问题诊断结果
经过测试确认,你的七牛云存储桶 `daoqires` **启用了防覆盖保护**
**测试证据:**
```
第一次上传:✅ 成功
第二次上传同名文件:❌ 失败
HTTP Status: 614
错误信息:{"error":"file exists"}
```
即使上传凭证设置了 `insertOnly: 0`,仍然无法覆盖,因为这是**存储桶级别的强制设置**。
---
## ✅ 解决方案
### 方案 1使用唯一文件名推荐 ⭐)
修改上传逻辑,自动为文件名添加时间戳或哈希值,避免文件名冲突。
#### 选项 A添加时间戳
```javascript
// 在 upload-to-qiniu.js 中修改 key 生成逻辑
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, -5);
const ext = path.extname(key);
const name = path.basename(key, ext);
key = `${name}_${timestamp}${ext}`;
```
**效果:**
```
report.pdf → report_2026-03-04T13-59-00.pdf
```
#### 选项 B添加哈希值
```javascript
const hash = crypto.createHash('md5').update(fileContent).digest('hex').slice(0, 8);
key = `${name}_${hash}${ext}`;
```
**效果:**
```
report.pdf → report_a3f5c2d1.pdf
```
#### 选项 C版本号递增
```javascript
// 检查文件是否存在,存在则递增版本号
let version = 1;
while (await fileExists(key)) {
key = `${name}_v${version}${ext}`;
version++;
}
```
**效果:**
```
report.pdf → report_v1.pdf → report_v2.pdf → ...
```
---
### 方案 2联系七牛云关闭防覆盖
**步骤:**
1. **登录七牛云控制台**
- https://portal.qiniu.com/
2. **进入对象存储**
- 选择存储桶 `daoqires`
3. **查找防覆盖设置**
- 设置 → 安全设置 → 禁止覆盖同名文件
- 或者:设置 → 空间设置 → 防覆盖
4. **关闭防覆盖**
- 如果找到该选项,关闭它并保存
5. **如果找不到选项**
- 联系七牛云客服400-808-5555
- 或提交工单申请关闭防覆盖
---
### 方案 3使用不同的存储桶
创建一个新的存储桶用于允许覆盖的场景:
```bash
# 在七牛云控制台创建新存储桶
# 创建时注意不要启用"防覆盖"选项
# 然后配置新存储桶
/qiniu-config set-bucket temp '{"accessKey":"...","secretKey":"...","bucket":"new-bucket-name","region":"z2","domain":"..."}'
# 上传到新存储桶
/upload /config/file.txt temp
```
---
## 📝 修改建议
如果你希望我修改上传脚本自动添加时间戳,请告诉我选择哪种方案:
- **时间戳**`filename_2026-03-04T13-59-00.pdf`
- **哈希值**`filename_a3f5c2d1.pdf`
- **版本号**`filename_v1.pdf`, `filename_v2.pdf`
或者,如果你能找到七牛云控制台的防覆盖设置并关闭它,覆盖功能就可以正常工作了。
---
## 📞 七牛云联系方式
- **客服电话**400-808-5555
- **工单系统**https://support.qiniu.com/
- **技术文档**https://developer.qiniu.com/
---
## 📊 测试结果汇总
| 测试场景 | 结果 | 说明 |
|----------|------|------|
| 第一次上传 | ✅ 成功 | 文件不存在,正常上传 |
| 第二次上传同名文件 | ❌ 失败 | HTTP 614 - file exists |
| 添加 insertOnly: 0 | ❌ 仍然失败 | 存储桶级别强制设置 |
| 修改 scope 不指定 key | ❌ 仍然失败 | 与 scope 无关 |
**结论:** 必须通过七牛云控制台关闭防覆盖,或使用唯一文件名。