npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

picgo-plugin-huawei-obs

v0.3.0

Published

A PicGo uploader plugin for Huawei Cloud OBS.

Readme

picgo-plugin-huawei-obs

PicGo 华为云 OBS 上传插件。

本插件用于将 PicGo 处理后的文件上传到华为云 OBS,并返回可访问 URL。主要使用场景是 PicGo 图片上传。华为云 OBS 本身支持上传任意对象,因此插件内部不会强制限制 MIME 类型;只要 PicGo 能将文件交给插件,就会按 OBS Object 上传。

功能特性

  • 支持华为云 OBS 上传
  • 支持 PicGo CLI 和 PicGo GUI
  • 支持自定义 OBS Endpoint
  • 支持自定义 Bucket
  • 支持自定义上传路径前缀
  • 支持日期目录,例如 YYYY/MM/DD
  • 支持自定义访问域名
  • 支持 HTTPS / HTTP 链接生成
  • 自动识别 Content-Type
  • 不强制限制 image/*
  • 上传失败时显示 PicGo 通知

安装

PicGo GUI

在 PicGo 插件市场中搜索:

huawei-obs

或者搜索完整包名:

picgo-plugin-huawei-obs

安装后,在图床设置中选择 华为云,并填写配置。

PicGo CLI

picgo install huawei-obs

也可以使用 npm 安装到 PicGo 配置目录:

cd ~/.picgo
npm install picgo-plugin-huawei-obs

然后配置并启用上传器:

picgo set uploader 华为云
picgo use uploader 华为云

配置项

| 字段 | 是否必填 | 说明 | |---|---:|---| | accessKeyId | 是 | 华为云 Access Key ID | | secretAccessKey | 是 | 华为云 Secret Access Key | | server | 是 | OBS Endpoint,例如 obs.cn-north-4.myhuaweicloud.com | | bucket | 是 | OBS Bucket 名称 | | path | 否 | 上传路径前缀,例如 picgo/images;不填则上传到桶根目录 | | datePath | 否 | 日期目录模板,例如 YYYY/MM/DD;不填则不使用日期目录 | | customDomain | 否 | 自定义域名,例如 img.example.com | | forceHttps | 否 | 是否使用 HTTPS 生成访问链接,默认 true | | acl | 否 | 对象 ACL,例如 public-read;不填则使用桶默认策略 | | storageClass | 否 | OBS StorageClass;不填则使用桶默认存储类型 |

配置示例

{
  "picBed": {
    "current": "华为云",
    "uploader": "华为云",
    "华为云": {
      "accessKeyId": "your-access-key-id",
      "secretAccessKey": "your-secret-access-key",
      "server": "obs.cn-north-4.myhuaweicloud.com",
      "bucket": "your-bucket",
      "path": "picgo",
      "datePath": "YYYY/MM/DD",
      "customDomain": "",
      "forceHttps": true,
      "acl": "",
      "storageClass": ""
    }
  }
}

日期目录

datePath 用于按时间生成上传目录。

支持以下模板变量:

| 变量 | 说明 | 示例 | |---|---|---| | YYYY | 年 | 2026 | | MM | 月 | 05 | | DD | 日 | 07 | | HH | 小时 | 13 | | mm | 分钟 | 12 | | ss | 秒 | 19 |

示例:

{
  "path": "picgo",
  "datePath": "YYYY/MM/DD"
}

上传后的 OBS Object Key 类似:

picgo/2026/05/07/example.png

如果只配置:

{
  "path": "",
  "datePath": "YYYY/MM"
}

上传后的 OBS Object Key 类似:

2026/05/example.png

如果 datePath 为空,则不会添加日期目录。

自定义域名

如果没有配置 customDomain,插件会生成 OBS 默认桶域名:

https://<bucket>.<server>/<object-key>

例如:

https://your-bucket.obs.cn-north-4.myhuaweicloud.com/picgo/example.png

如果配置:

{
  "customDomain": "img.example.com"
}

则生成:

https://img.example.com/picgo/example.png

customDomain 可以填写:

img.example.com

也可以填写:

https://img.example.com

插件会自动去除协议部分,并根据 forceHttps 生成最终 URL。

访问权限

如果上传成功但 URL 无法直接访问,通常是 OBS 权限问题。

用于图床时,建议使用以下方式之一。

方式一:设置 Bucket 公共读

在华为云 OBS 控制台中,将 Bucket 或指定目录设置为公共读。

适合公开图床场景。

方式二:设置对象 ACL

在插件配置中设置:

{
  "acl": "public-read"
}

然后重新上传图片。

如果对象仍然无法公开访问,请优先检查 Bucket Policy。

本地验证

使用 PicGo CLI 测试:

picgo upload ./test.png

查看详细日志:

picgo -d upload ./test.png

成功后会输出类似:

https://your-bucket.obs.cn-north-4.myhuaweicloud.com/picgo/2026/05/07/test.png

下载该 URL 后,文件应该可以正常打开。

本地开发

克隆仓库:

git clone https://github.com/huqi1024/picgo-plugin-huawei-obs.git
cd picgo-plugin-huawei-obs

安装依赖:

npm install

检查语法:

npm run lint

将本地插件安装到 PicGo CLI 配置目录:

cd ~/.picgo
npm install /path/to/picgo-plugin-huawei-obs

配置并测试:

picgo set uploader 华为云
picgo use uploader 华为云
picgo -d upload ./test.png

发布

发布前检查:

npm run lint
npm pack --dry-run

发布到 npm:

npm publish

创建版本标签:

git tag v0.2.0
git push origin main
git push origin v0.2.0

常见问题

上传成功,但下载后的图片无法打开

请确认使用的是 0.1.1 或更高版本。

早期测试版本可能会错误地上传 Buffer,导致 OBS 中的对象内容损坏。当前版本已经改为使用 Readable Stream 上传 PicGo 输出,避免该问题。

如果已经上传过损坏对象,建议删除 OBS 中的旧对象后重新上传。

上传成功,但 URL 返回 403

通常说明对象不是公开可读。

请检查:

  • Bucket Policy
  • Object ACL
  • 是否设置了 acl: "public-read"
  • 当前 AK/SK 是否有设置对象 ACL 的权限

上传成功,但 URL 返回 404

请检查:

  • server 是否为正确的 OBS 区域 Endpoint
  • bucket 是否正确
  • pathdatePath 是否改变了对象路径
  • OBS 控制台中是否存在该对象

URL 中出现 ""

通常说明配置时输入了字面量引号。

错误示例:

{
  "path": "\"\"",
  "customDomain": "\"\""
}

正确示例:

{
  "path": "",
  "customDomain": ""
}

插件会尝试自动清理常见的纯引号值,但仍建议保持配置干净。

PicGo 提示 uploader duplicate id

说明另一个插件注册了相同的上传器 ID。

列出本地 PicGo 插件:

ls ~/.picgo/node_modules | grep picgo-plugin

如有冲突,卸载对应插件:

cd ~/.picgo
npm uninstall <plugin-name>

安全说明

不要将包含 AK/SK 的 PicGo 配置文件提交到 Git 仓库。

建议:

  • AK/SK 只保存在本地 PicGo 配置中
  • 使用最小权限 IAM 策略
  • 使用专用 OBS Bucket 作为图床
  • 定期轮换 AK/SK
  • 不要盲目执行 npm audit fix --force

已知的 npm audit 提示可能来自上游依赖,例如:

  • fast-xml-parser 来自 esdk-obs-nodejs
  • tmp 来自 picgo -> inquirer -> external-editor

这些问题应在上游发布兼容修复后再跟进升级。

说明

本插件主要为 PicGo 图片上传场景设计。

华为云 OBS 支持上传任意对象。本插件不会主动阻止非图片 MIME 类型,但 PicGo 本身主要围绕图片上传、剪贴板图片、图片预览和 Markdown 图片链接设计,因此非图片文件不是主要兼容目标。

License

MIT