← 返回 Skills 市场
yangdong2398

Baidu Cloud BOS

作者 yang · GitHub ↗ · v1.1.2 · MIT-0
cross-platform ✓ 安全检测通过
316
总下载
1
收藏
1
当前安装
10
版本数
在 OpenClaw 中安装
/install baidu-cloud-bos
功能描述
百度智能云对象存储(BOS)集成技能。支持文件上传/下载/删除/复制、列出文件与 Bucket、获取签名 URL、 图片处理(亮度、对比度、模糊、旋转、缩放、裁剪、圆形裁切、圆角、质量压缩、水印等)、 目录递归上传/下载及增量同步。通过 Node.js SDK 脚本(优先)和 bcecmd 命令行工具双方式管理,...
使用说明 (SKILL.md)

百度智能云 BOS 技能

通过 Node.js SDK 脚本 + bcecmd 工具管理百度智能云对象存储(BOS)。

首次使用 — 自动设置

当用户首次要求操作 BOS 时,按以下流程操作:

步骤 1:检查当前状态

{baseDir}/scripts/setup.sh --check-only

如果输出显示一切 OK(SDK 已安装、凭证已配置),跳到「执行策略」。

步骤 2:如果未配置,引导用户提供凭证

告诉用户:

我需要你的百度智能云凭证来连接 BOS 存储服务。请提供:

  1. AccessKeyId — 百度云 AK
  2. SecretAccessKey — 百度云 SK
  3. Endpoint — BOS 服务端点(如 bj.bcebos.comgz.bcebos.comsu.bcebos.com
  4. Bucket — 存储桶名称(如 my-bucket
  5. StsToken(可选) — 临时安全凭证的 SessionToken

你可以在 百度智能云控制台 > 安全认证 > Access Key 获取密钥, 在 BOS 控制台 查看存储桶信息。

Endpoint 对照表

区域 Endpoint
北京 bj.bcebos.com
广州 gz.bcebos.com
苏州 su.bcebos.com
保定 bd.bcebos.com
香港 hkg.bcebos.com

步骤 3:用户提供凭证后,运行自动设置

{baseDir}/scripts/setup.sh --ak "\x3CAccessKeyId>" --sk "\x3CSecretAccessKey>" --endpoint "\x3CEndpoint>" --bucket "\x3CBucket>"

脚本会自动:

  • 检查并安装 @baiducloud/sdk(Node.js SDK)
  • 检查 bcecmd 是否已安装
  • 将凭证持久化到 ~/.config/openclaw/baidu-cloud-bos/credentials.json(权限 600)
  • 将凭证导出到当前 session 环境变量
  • 配置 bcecmd(如已安装)
  • 验证 BOS 连接

凭证读取优先级:环境变量 > credentials.json 配置文件。后续新 session 无需重新配置。

执行策略

两种方式按优先级降级,确保操作始终可完成:

  1. 方式一:Node.js SDK 脚本(优先) — 通过 scripts/bos_node.mjs 执行存储操作
  2. 方式二:bcecmd 命令行 — 通过 shell 命令执行存储操作,支持目录同步
Node.js + @baiducloud/sdk 可用?
  ├─ 是 → 使用方式一(单文件操作,JSON 输出,适合程序化处理)
  └─ 否 → bcecmd 可用?(which bcecmd)
            ├─ 是 → 使用方式二(全功能,含目录同步)
            └─ 否 → 运行 setup.sh 安装

判断方式一node -e "require('@baiducloud/sdk')" 成功则可用。 判断方式二which bcecmd 有输出则可用。


方式一:Node.js SDK 脚本(优先)

官方文档: https://cloud.baidu.com/doc/BOS/s/Djwvyrhiw

当使用方式一时,通过 scripts/bos_node.mjs 执行存储操作。凭证读取优先级:环境变量 > ~/.config/openclaw/baidu-cloud-bos/credentials.json

支持的凭证来源:

  • 环境变量(优先):BCE_ACCESS_KEY_ID / BCE_SECRET_ACCESS_KEY / BCE_BOS_ENDPOINT / BCE_BOS_BUCKET(必需),BCE_STS_TOKEN(可选,临时凭证)
  • 配置文件(回退):~/.config/openclaw/baidu-cloud-bos/credentials.json

常用命令

以下省略 node {baseDir}/scripts/bos_node.mjs 前缀。完整格式:node {baseDir}/scripts/bos_node.mjs \x3Caction> [options]

# 上传文件
upload --file /path/to/file.jpg --key remote/path/file.jpg

# 上传字符串内容
put-string --content "文本内容" --key remote/file.txt --content-type "text/plain"

# 下载文件
download --key remote/path/file.jpg --output /path/to/save/file.jpg

# 列出文件
list --prefix "images/" --max-keys 100

# 获取签名 URL
sign-url --key remote/path/file.jpg --expires 3600

# 图片处理:亮度调整(-100 到 100)
sign-url --key remote/path/image.jpg --bright -5

# 图片处理:对比度调整(-100 到 100)
sign-url --key remote/path/image.jpg --contrast -30

# 图片处理:模糊(半径,标准差,各 1-50)
sign-url --key remote/path/image.jpg --blur 2,50

# 图片处理:旋转(-360 到 360,正数顺时针)
sign-url --key remote/path/image.jpg --rotate 90

# 图片处理:按 EXIF 自适应旋转
sign-url --key remote/path/image.jpg --auto-orient 1

# 图片处理:多操作链式(便捷 flag 可组合)
sign-url --key remote/path/image.jpg --bright 10 --contrast 20

# 图片处理:多参数操作用 --process 直传(缩放、裁剪、水印等)
sign-url --key remote/path/image.jpg --process "image/resize,m_lfit,w_800"
sign-url --key remote/path/image.jpg --process "image/crop,x_10,y_10,w_200,h_200"
sign-url --key remote/path/image.jpg --process "image/circle,r_100"
sign-url --key remote/path/image.jpg --process "image/rounded-corners,r_50"
sign-url --key remote/path/image.jpg --process "image/quality,q_80"
sign-url --key remote/path/image.jpg --process "image/watermark,text_aGVsbG8=,g_9"
sign-url --key remote/path/image.jpg --process "image/bright,b_10/resize,m_lfit,w_800"

# 获取图片详细信息(宽高、格式、色彩深度、透明通道等)
# 注意:sign-url 只生成 URL,需配合 curl 获取结果
sign-url --key remote/path/image.jpg --process "image/info"
# curl -s "$(上述命令输出的 url)"

# resize 模式:lfit=等比缩小至框内,mfit=等比放大至框外,fill=填充裁剪,pad=填充空白,fixed=强制宽高
# 水印 text 参数需 URL-safe Base64 编码:标准 base64 后将 + → -,/ → _,去掉尾部 =

# 查看文件信息(HEAD)
head --key remote/path/file.jpg

# 删除文件
delete --key remote/path/file.jpg

# 复制文件(同桶或跨桶)
copy --source-bucket \x3Cbucket> --source-key \x3Ckey> --key \x3Cdest-key>

# 列出所有 Bucket
list-buckets

所有命令输出 JSON 格式,success: true 表示成功,退出码 0。

限制

仅支持单文件操作,不支持目录递归上传/下载/同步(请用方式二 bcecmd)。图片处理为方式一独有功能。


方式二:bcecmd 命令行

官方文档: https://cloud.baidu.com/doc/BOS/s/kmcn3zrup

当方式一不可用时使用。bcecmd 是百度云官方命令行工具,支持目录同步等高级功能。

首次配置

bcecmd --conf-path ~/.bcecmd configure \
  --access-key \x3CAK> \
  --secret-key \x3CSK> \
  --domain \x3CEndpoint>

配置文件保存在 ~/.bcecmd/credentials~/.bcecmd/config

常用命令

# 上传文件
bcecmd bos cp /path/to/file.jpg bos:/\x3Cbucket>/remote/path/file.jpg

# 上传目录(递归)
bcecmd bos cp /path/to/folder/ bos:/\x3Cbucket>/remote/folder/ --recursive

# 下载文件
bcecmd bos cp bos:/\x3Cbucket>/remote/path/file.jpg /path/to/save/file.jpg

# 下载目录(递归)
bcecmd bos cp bos:/\x3Cbucket>/remote/folder/ /path/to/save/ --recursive

# 列出文件
bcecmd bos ls bos:/\x3Cbucket>/images/

# 删除文件
bcecmd bos rm bos:/\x3Cbucket>/remote/path/file.jpg

# 递归删除目录
bcecmd bos rm bos:/\x3Cbucket>/remote/folder/ --recursive --yes

# 同步本地目录到 BOS
bcecmd bos sync /path/to/local/ bos:/\x3Cbucket>/remote/ --delete

# 同步 BOS 目录到本地
bcecmd bos sync bos:/\x3Cbucket>/remote/ /path/to/local/ --delete

# 查看文件元信息
bcecmd bos head bos:/\x3Cbucket>/remote/path/file.jpg

# 获取签名 URL(默认 1800 秒,-e 后直接跟秒数无空格;-e-1 为永久有效)
bcecmd bos gen_signed_url bos:/\x3Cbucket>/remote/path/file.jpg -e3600
bcecmd bos gen_signed_url bos:/\x3Cbucket>/remote/path/file.jpg -e-1

# 列出所有 Bucket
bcecmd bos ls

# 创建 Bucket
bcecmd bos mb bos:/\x3Cbucket>

# 删除 Bucket(必须为空)
bcecmd bos rb bos:/\x3Cbucket>

# 常用全局参数
# --exclude \x3CPATTERN>  排除匹配的文件(支持上传/下载/同步)
# --include \x3CPATTERN>  仅包含匹配的文件
# --conf-path \x3CPATH>   指定配置目录(默认 ~/.bcecmd)
# 示例:同步时排除日志文件
bcecmd bos sync /path/to/local/ bos:/\x3Cbucket>/remote/ --delete --exclude "*.log"

优势

  • 目录同步bcecmd bos sync 支持增量同步、--delete 删除远端多余文件
  • 递归操作--recursive 支持目录级别的上传/下载/删除
  • 大文件:自动分片上传
  • Bucket 管理:创建/删除 Bucket

功能对照表

功能 方式一 Node.js SDK 方式二 bcecmd
上传文件
上传字符串/内容
下载文件
列出文件
获取签名 URL
图片处理(签名 URL)
删除文件
查看文件信息
复制文件 ✅(cp 命令)
递归上传/下载目录
目录同步(增量)
Bucket 管理 ✅(list) ✅(创建/删除/列表)
JSON 结构化输出

使用规范

  1. 首次使用先运行 {baseDir}/scripts/setup.sh --check-only 检查环境
  2. 凭证不明文展示:引导用户自行通过 setup.sh 或编辑配置文件设置
  3. 所有文件路径--key/BOS 路径)为存储桶内的相对路径,如 images/photo.jpg
  4. bcecmd 路径格式bos:/\x3Cbucket>/path/to/file,注意 bos:/ 前缀
  5. 上传后主动获取链接:上传完成后调用 sign-url(方式一)或 gen_signed_url(方式二)返回访问链接
  6. 错误处理:调用失败时先用 setup.sh --check-only 诊断环境问题
  7. 大批量操作优先用 bcecmd:目录同步、批量上传等场景推荐方式二
  8. 方式一脚本源码scripts/bos_node.mjs
  9. API 参考文档references/api_reference.md
安全使用建议
This package appears to do what it says: manage Baidu BOS via the Node SDK or bcecmd. Before installing or running it, consider: (1) It will ask for your AccessKeyId/SecretAccessKey (or optional STS token) and will write them to ~/.config/openclaw/baidu-cloud-bos/credentials.json (setup.sh sets file perms to 600) and export them into the current session — only supply long-lived credentials if you trust the skill/author. Prefer using temporary STS credentials with least privilege and a limited lifetime. (2) The tool can generate signed URLs (bcecmd supports permanent links with -e -1) — be careful about creating publicly accessible permanent URLs. (3) The registry metadata did not declare required env vars; confirm you are comfortable with the code (scripts/bos_node.mjs and setup.sh are included and readable). (4) If you are unsure about trust, run setup and operations in an isolated environment (dedicated VM/container or throwaway user account) and delete the credentials file when finished.
功能分析
Type: OpenClaw Skill Name: baidu-cloud-bos Version: 1.1.2 The skill bundle provides a legitimate integration for Baidu Cloud Object Storage (BOS). It includes a setup script (setup.sh) that correctly handles environment preparation, dependency installation, and credential persistence with security best practices such as input validation via regex and restricted file permissions (chmod 600). The Node.js implementation (bos_node.mjs) uses the official Baidu Cloud SDK to perform standard storage operations like uploading, downloading, and generating signed URLs. No evidence of malicious intent, data exfiltration to unauthorized endpoints, or prompt injection was found; the code is well-structured and aligns perfectly with its stated purpose.
能力评估
Purpose & Capability
The skill name/description (Baidu BOS integration) matches the delivered files and behavior: a Node.js wrapper (scripts/bos_node.mjs) and setup script (scripts/setup.sh) that use @baiducloud/sdk or bcecmd to upload/download/list objects and perform image processing. One minor incoherence: the registry metadata declares no required env vars or primary credential, but the SKILL.md and code clearly require and use Baidu credentials (BCE_ACCESS_KEY_ID, BCE_SECRET_ACCESS_KEY, BCE_BOS_ENDPOINT, BCE_BOS_BUCKET). This omission is likely a metadata oversight rather than malicious.
Instruction Scope
Runtime instructions explicitly ask the agent/user for secret credentials and direct running scripts/setup.sh which will persist credentials to ~/.config/openclaw/baidu-cloud-bos/credentials.json and export them into the current session. The scripts operate on arbitrary local paths (upload/download/sync) and may create signed URLs (including permanent via -e -1). All referenced operations are within the expected scope of an object-storage skill, but the instructions do include persistent storage of secrets and generation of potentially public links.
Install Mechanism
There is no formal install spec in the registry; the provided setup.sh will run local npm install @baiducloud/sdk in the skill directory (standard npm registry) when configured. No downloads from personal servers or URL shorteners are present. The use of npm (public registry) is expected for a Node.js SDK but does execute provider code when run.
Credentials
The skill requires only Baidu BOS credentials (AK/SK, optional STS token, endpoint, bucket), which are proportionate to its functionality. It will persist those credentials to ~/.config/openclaw/baidu-cloud-bos/credentials.json (setup.sh writes this file with mode 600) and also export them into the current shell session. The lack of declared required env vars in the package metadata is an inconsistency to be aware of.
Persistence & Privilege
The skill does persist credentials to the user's home directory and configures bcecmd if present; it does not request always:true or attempt to modify other skills or system-wide settings beyond its own files and the user's ~/.bcecmd config. The persisted credentials remain available to any process with access to that user account unless removed.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install baidu-cloud-bos
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /baidu-cloud-bos 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.2
更新 skill 描述:补充图片处理、目录同步能力说明,去掉负面表述,加入凭证持久化说明
v1.1.1
修正 display name 为 Baidu Cloud BOS
v1.1.0
图片处理能力全量补齐:新增 contrast(对比度)、blur(模糊)、rotate(旋转)、auto-orient(自适应旋转) 便捷 flag;支持 resize、crop、circle、rounded-corners、quality、watermark(文字/图片)、info 通过 --process 直传;同步去掉 Python SDK 方式,仅保留 Node.js SDK 和 bcecmd 双方式
v1.0.6
凭证持久化: 支持 ~/.config/openclaw/baidu-cloud-bos/credentials.json, 新 session 无需重新配置
v1.0.5
更新 description、修复 Endpoint 表格显示效果
v1.0.4
修复显示名(Skills → Baidu Cloud BOS)、清理 package.json、排除 package-lock.json
v1.0.3
修复 bcecmd 签名 URL 命令(gen_signed_url)、修复 Node.js copyObject 参数顺序、更新使用规范描述
v1.0.2
修正文档链接、统一两份文档的 Endpoint 表格、修复描述冗余
v1.0.1
修正 Endpoint 域名(香港区域更新为 hkg.bcebos.com,移除部分区域)
v1.0.0
Initial release
元数据
Slug baidu-cloud-bos
版本 1.1.2
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 10
常见问题

Baidu Cloud BOS 是什么?

百度智能云对象存储(BOS)集成技能。支持文件上传/下载/删除/复制、列出文件与 Bucket、获取签名 URL、 图片处理(亮度、对比度、模糊、旋转、缩放、裁剪、圆形裁切、圆角、质量压缩、水印等)、 目录递归上传/下载及增量同步。通过 Node.js SDK 脚本(优先)和 bcecmd 命令行工具双方式管理,... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 316 次。

如何安装 Baidu Cloud BOS?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install baidu-cloud-bos」即可一键安装,无需额外配置。

Baidu Cloud BOS 是免费的吗?

是的,Baidu Cloud BOS 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Baidu Cloud BOS 支持哪些平台?

Baidu Cloud BOS 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Baidu Cloud BOS?

由 yang(@yangdong2398)开发并维护,当前版本 v1.1.2。

💬 留言讨论