🌹 图床附件 🌹

plugin-picbed-dominickonode —— Halo 的附件存储插件,将GitHub图床添加为附件策略,配合Cloudflare代理,实现国内也能顺畅访问,支持重命名格式,避免文件名冲突。

特性

  • 基于 Halo AttachmentHandler 扩展点,安装启用后,在「附件 → 存储策略」里新建「🌹图床附件🌹 @DKK」即可使用。

  • 上传/删除走 GitHub REST API,公开访问默认走你的 Cloudflare 自定义域名(干净、不带 token,仓库私有也能读)。

  • 支持重命名格式:{y}/{m}/{d}{h}{i}、{origin}、{timestamp}、{rand:N}。

  • GitHub Token 存于 Halo Secret,绝不明文落库。

  • 上传/删除按「仓库+分支」串行,兼容 GitHub 并发写分支的 ref 竞态问题。

使用教程

  1. 安装本插件并启用。

  2. 前往 附件 → 存储策略 → 新建,选择「🌹图床附件🌹 @DKK」。

  3. 填写以下配置。

配置项说明

配置说明示例
图床类型目前仅 GitHub;阿里云 OSS 敬请期待(开摆)github
仓库存放附件的仓库,格式 owner/repoDominic-KK/xxxxxx
分支仓库分支main
存储路径前缀仓库内文件前缀,建议以 / 结尾halo-atta/
GitHub API 基地址上传/删除接口。默认 https://api.github.com;国内直连不稳时再填自建代理,如果你不知道这是什么,建议保持默认。https://api.github.com
自定义域名公开访问域名,推荐 Cloudflare 代理,这是本插件推荐的方式,走这里拼接 permalinkhttps://your-domain.com
GitHub Token只读/可写 Personal Access Token(存 Secret)创建 fine-grained token:限定你的图床仓库,权限必选 Contents: Read and write(自动附带只读 Metadata)
重命名格式生成仓库内文件名{y}/{m}/{d}{h}{i}-{rand:3}

如果你还没有自己的GitHub图床或自定义代理域名,可以看看这篇文章👇

📄((20260225142351-9xqpnik 'GitHub + Cloudflare + Picgo 搭建你的免费图床'))

与 PicGo-github 插件的对应关系:仓库/分支/存储路径/自定义域名/重命名格式 分别对应你 PicGo 里的 github.repo / branch / path / customUrl / picgo-plugin-rename-file.format,可直接照搬。

// picgo github 插件配置
{
  "picBed": {
    "current": "github",
    "github": {
      "repo": "Dominic-KK/xxxxxx",
      "branch": "main",
      "token": "ghp_xxxxxx",
      "path": "picgo/",
      "customUrl": "https://your-domain.com"
    }
  },
  "picgoPlugins": {
    "github": true,
    "picgo-plugin-rename-file": true
  },
  "picgo-plugin-rename-file": {
    "format": "{y}/{m}/{d}{h}{i}-{rand:3}"
  }
}
预览
源码

GitHub storage

Attachment workflow

Policy and lifecycle

disposes

configures

watches changes

uploads or deletes

reads settings

generates object key

reads token

sends upload/delete requests

writes or deletes files

creates metadata

builds public link

Plugin lifecycle
[PicbedPlugin.java]

Policy watcher

Storage policy

Attachment handler

Object-key generator

Halo attachment

Halo token Secret

GitHub REST API

GitHub repository

Custom public domain

Halo administrator

flowchart TD

subgraph group_policy["Policy and lifecycle"]
  node_plugin["Plugin lifecycle<br/>[PicbedPlugin.java]"]
  node_watcher["Policy watcher"]
  node_policy_config["Storage policy"]
end

subgraph group_attachment["Attachment workflow"]
  node_handler["Attachment handler"]
  node_filename["Object-key generator"]
  node_attachment_record["Halo attachment"]
end

subgraph group_github["GitHub storage"]
  node_token_secret[("Halo token Secret")]
  node_github_api["GitHub REST API"]
  node_repository[("GitHub repository")]
  node_custom_domain["Custom public domain"]
end

node_halo(("Halo administrator"))

node_plugin -->|"disposes"| node_watcher
node_halo -->|"configures"| node_policy_config
node_watcher -->|"watches changes"| node_policy_config
node_halo -->|"uploads or deletes"| node_handler
node_handler -->|"reads settings"| node_policy_config
node_handler -->|"generates object key"| node_filename
node_handler -->|"reads token"| node_token_secret
node_handler -->|"sends upload/delete requests"| node_github_api
node_github_api -->|"writes or deletes files"| node_repository
node_handler -->|"creates metadata"| node_attachment_record
node_attachment_record -->|"builds public link"| node_custom_domain

click node_plugin "https://github.com/dominic-kk/halo-plugin-picbed/blob/main/src/main/java/top/dominickk/picbed/PicbedPlugin.java"
click node_watcher "https://github.com/dominic-kk/halo-plugin-picbed/blob/main/src/main/java/top/dominickk/picbed/PolicyConfigWatcher.java"
click node_policy_config "https://github.com/dominic-kk/halo-plugin-picbed/blob/main/src/main/resources/extensions/setting-picbed.yaml"
click node_handler "https://github.com/dominic-kk/halo-plugin-picbed/blob/main/src/main/java/top/dominickk/picbed/provider/GitHubAttachmentHandler.java"
click node_filename "https://github.com/dominic-kk/halo-plugin-picbed/blob/main/src/main/java/top/dominickk/picbed/tools/FileNameGenerator.java"
click node_attachment_record "https://github.com/dominic-kk/halo-plugin-picbed/blob/main/src/main/java/top/dominickk/picbed/provider/GitHubAttachmentHandler.java"
click node_token_secret "https://github.com/dominic-kk/halo-plugin-picbed/blob/main/src/main/java/top/dominickk/picbed/provider/GitHubAttachmentHandler.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_plugin,node_watcher,node_policy_config toneBlue
class node_handler,node_filename,node_attachment_record toneAmber
class node_token_secret,node_github_api,node_repository,node_custom_domain toneMint
class node_halo toneIndigo

diagram

图床附件 / 1 0 字 0 行 dominicmaple
2026-10-04T15:07:06.504715241Z 2026-10-04T15:07:20.214198887Z