Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/support r2 beta #207

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Feature/support r2 beta #207

wants to merge 8 commits into from

Conversation

xyTom
Copy link
Collaborator

@xyTom xyTom commented Dec 1, 2024

此分支是支持R2作为图片存储后端的实验性分支(Beta)用于实验R2作为图片储存位置的可能性

以下是如何配置和使用 R2 存储的说明文档:

Telegraph-Image R2 存储配置指南

本地开发配置

  1. 本地开发时使用以下命令启动项目:
npx wrangler pages dev ./ \
  --kv "img_url" \
  --port 8080 \
  --binding BASIC_USER=admin \
  --binding BASIC_PASS=123 \
  --persist-to ./data \
  --r2 BUCKET \
  --binding UPLOAD_MODE=R2

线上环境配置

  1. 在 Cloudflare Dashboard 创建 R2 bucket:

    • 进入 R2 页面
    • 点击 "Create bucket"
    • 输入 bucket 名称(例如:my-images)
  2. 在 Pages 项目设置中绑定 R2:

    • 进入项目的 "Settings" > "Functions"
    • 在 "R2 Buckets" 部分
    • 点击 "Add binding"
    • Variable name 设置为 BUCKET
    • 选择已创建的 bucket
  3. 设置环境变量:

    • 在 "Settings" > "Environment variables"
    • 添加 UPLOAD_MODE=R2

注意事项

  1. 本地开发时,文件会存储在 ./data 目录下
  2. R2 存储模式下,文件URL格式为 /file/[filename]
  3. 建议配置自定义域名以获得更好的访问体验
  4. 数据存储限额和计费请参考 Cloudflare R2 pricing

Copy link

cloudflare-workers-and-pages bot commented Dec 1, 2024

Deploying tpic with  Cloudflare Pages  Cloudflare Pages

Latest commit: d409c69
Status: ✅  Deploy successful!
Preview URL: https://46a3a344.tpic.pages.dev
Branch Preview URL: https://feature-support-r2-beta.tpic.pages.dev

View logs

@xyTom xyTom mentioned this pull request Dec 1, 2024
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.

2 participants