Skip to content

feat(driver): add Cloudflare Image Bed support#2427

Open
ZZ0YY wants to merge 6 commits intoOpenListTeam:mainfrom
ZZ0YY:feat/cfimgbed
Open

feat(driver): add Cloudflare Image Bed support#2427
ZZ0YY wants to merge 6 commits intoOpenListTeam:mainfrom
ZZ0YY:feat/cfimgbed

Conversation

@ZZ0YY
Copy link
Copy Markdown

@ZZ0YY ZZ0YY commented May 1, 2026

Description / 描述

目前实现了列表和下载功能,上传功能后续再做,先提一个 PR,看看意见

Add a new storage driver for Cloudflare Image Bed https://github.com/MarSeventh/CloudFlare-ImgBed
(a popular image hosting solution based on Cloudflare Workers & KV/D1).
Features implemented:

  • List: Support for file and directory listing with custom RootPath (subdirectory) mounting.
  • Link: Direct download/view links for images and files.
  • Metadata: Correctly parses file size, modification time (from timestamp), and MIME types from API metadata.

Cloudflare Image Bed
https://github.com/MarSeventh/CloudFlare-ImgBed
(基于 Cloudflare Workers 和 KV/D1 的图床方案)新增存储驱动。
实现功能:

  • 列表 (List):支持文件和目录列表,支持自定义根目录(子目录)挂载。
  • 直链 (Link):支持获取图片的直链下载/预览地址。
  • 元数据 (Metadata):正确解析 API 返回的文件大小、修改时间(时间戳转换)及 MIME 类型。

Motivation and Context / 背景

Cloudflare Image Bed is a lightweight and free-tier-friendly image hosting tool. Integrating it into OpenList allows users to manage their Cloudflare-based image assets alongside other storage services.

Cloudflare Image Bed 是一个轻量且对免费用户友好的图床工具。通过将其集成到 OpenList,用户可以方便地与其他存储服务一起管理其在 Cloudflare 上的图片资产。

Relates to #376 (Add more storage drivers)

How Has This Been Tested? / 测试

  • Environment: Go 1.24, Windows 10.

  • Manual Test:

    1. Mounted a real CFImgBed instance with Token.
    2. Verified that all files and folders are listed correctly in the dashboard.
    3. Verified that files in subdirectories are accessible when using a specific RootPath.
    4. Verified that images can be previewed/downloaded via the generated links.
  • Debug: Used resty debug mode to ensure HTTP requests/responses are handled correctly.

  • 环境:Go 1.24, Windows 10。

  • 手动测试

    1. 使用真实的 CFImgBed 实例和 Token 进行了挂载。
    2. 验证了所有文件和文件夹在面板中正确列出。
    3. 验证了设置“根目录路径”后,子目录下的文件访问正常。
    4. 验证了生成的图片直链可以正常预览和下载。
  • 调试:开启 resty 的调试模式,确保 HTTP 请求和响应逻辑无误。

Checklist / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt.
    我已使用 go fmt 格式化提交的代码。
  • I have added appropriate labels to this PR.
    我已为此 PR 添加了适当的标签。
  • I have updated the repository accordingly.
    我已相应更新了相关仓库。

@ZZ0YY ZZ0YY mentioned this pull request May 1, 2026
9 tasks
Copy link
Copy Markdown
Member

@jyxjjj jyxjjj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

驱动名称 还有别瞎删文件 Issue 也不是给你找审核用的

@jyxjjj
Copy link
Copy Markdown
Member

jyxjjj commented May 1, 2026

可能违反使用政策

@ZZ0YY
Copy link
Copy Markdown
Author

ZZ0YY commented May 1, 2026

驱动名称 还有别瞎删文件 Issue 也不是给你找审核用的

不好意思 不熟悉流程,急于询问相关要求 所以提了个 issue。入门试一试,前端构建文件忘记弄回去了

@ZZ0YY
Copy link
Copy Markdown
Author

ZZ0YY commented May 1, 2026

可能违反使用政策

应该没有吧,单纯看使用者使用什么存储后端,比如我自己是用 S3和 Cloudflare 自己的对象存储,完全合规。较少使用Huface 和 telegram 存储文件
我写这个主要是为了方便上传

ZZ0YY and others added 2 commits May 1, 2026 14:00
- Rename driver identifier and directory to 'cloudflare_imgbed' for consistency.
- Remove invalid 'replace' directive in go.mod.
- Restore accidentally modified/deleted files in public/dist.
- Update driver registration in drivers/all.go.

Co-authored-by: Copilot <copilot@github.com>
@ZZ0YY
Copy link
Copy Markdown
Author

ZZ0YY commented May 1, 2026

抱歉,我是第一次为Openlist贡献代码,对命名规范和 Module 处理不熟悉 已经按照建议更正了驱动名称(改为 cloudflare_imgbed),并移除了 go.mod 中的 replace 逻辑,已经更正了,请有空再指教
屏幕截图 2026-05-01 105822

顺便补个运行截图
屏幕截图 2026-05-01 105803

@ZZ0YY ZZ0YY requested a review from jyxjjj May 1, 2026 06:08
Comment thread drivers/cloudflare_imgbed/driver.go Outdated
Comment thread drivers/cloudflare_imgbed/meta.go Outdated
ZZ0YY and others added 3 commits May 1, 2026 17:48
Co-authored-by: Copilot <copilot@github.com>
…tion with improved error handling and pagination
@ZZ0YY
Copy link
Copy Markdown
Author

ZZ0YY commented May 1, 2026

@xrgzs 您好 新的提交进行了
1:错误处理优化:增强了对 API 返回异常的捕获与处理,提高稳定性。
2:分页支持:新增了分页功能,有效应对大数据量返回时的性能消耗。
其背景是图片往往有上千张上万张,之前的写法可能性能此时会不好。本人一个目录下3240张图片经过测试没啥问题,虽然可能不太专业
3:使用utils.EncodePath(fullPath) 进行安全编码

并且使用了中文注释,进行了分页测试,没有问题 您可以直接查看这个commit 36aecbf

以下是截图
屏幕截图 2026-05-02 015103

@ZZ0YY ZZ0YY force-pushed the feat/cfimgbed branch from 8ee3f67 to 36aecbf Compare May 1, 2026 23:25
@ZZ0YY
Copy link
Copy Markdown
Author

ZZ0YY commented May 1, 2026

不好意思 刚刚在调试 build 工作流 拉 snap 老是不成功

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants