Cloudflare R2 Upload logo

Cloudflare R2 Upload

Community
Innei
cloudflare-r2-upload

Use when uploading one or many files to a Cloudflare R2 bucket and returning public URLs via a bound custom domain. Covers wrangler CLI and the REST API (Cloudflare API token) paths, batched uploads, MIME handling, correct account selection for multi-account setups, and post-upload public-URL verification. Triggers on tasks like "upload these images to R2", "push assets to the uploads bucket", "put files under <prefix>/ on R2".

Overview

PublisherInnei
RepositorySKILL
Skill namecloudflare-r2-upload
Stars
81
Forks
2
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by Innei on GitHub. Read the source before you install it.

Installation

Install the Cloudflare R2 Upload AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Innei/SKILL.git /tmp/SKILL
mkdir -p .claude/skills
cp -r /tmp/SKILL/skills/infrastructure/cloudflare-r2-upload .claude/skills/cloudflare-r2-upload
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Cloudflare R2 Upload in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Cloudflare R2 Upload on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Cloudflare R2 Upload is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Cloudflare R2 Upload

Use this skill when the task requires pushing local files to a Cloudflare R2 bucket and producing stable public URLs through a bound custom domain (for example object.innei.in).

Scope

  • Target task class: single-file or batched uploads into one R2 bucket under a specified key prefix.
  • Supported auth paths:
    • wrangler CLI with an existing OAuth session.
    • wrangler CLI with CLOUDFLARE_API_TOKEN env (from a Cloudflare API token, e.g. stored as R2_API_KEY).
  • Out of scope: bucket creation, custom-domain binding, CORS / lifecycle config, signed URLs, multipart uploads of files >300 MB.

Inputs

VariableMeaning
R2_API_KEYCloudflare API token with R2 write scope. Optional if wrangler already has an OAuth session.
CLOUDFLARE_ACCOUNT_IDCloudflare account that owns the bucket. Required if the authenticated user belongs to multiple accounts.
BUCKETTarget R2 bucket name (e.g. uploads).
KEY_PREFIXObject key prefix, e.g. mx-space/topics/. Always ends with /.
PUBLIC_DOMAINCustom domain bound to the bucket, e.g. object.innei.in.
SRC_DIRLocal directory containing files to upload.

Workflow

text
[1] Identify account + bucket
      -> wrangler whoami to list accounts
      -> wrangler r2 bucket list (per candidate account) to find BUCKET

[2] Upload each file
      -> wrangler r2 object put BUCKET/KEY --file=PATH --content-type=MIME --remote

[3] Verify via public domain
      -> curl -sI https://PUBLIC_DOMAIN/KEY and assert HTTP 200

[4] Report final URLs
      -> https://PUBLIC_DOMAIN/KEY for each uploaded file

Auth Setup

Prefer an existing wrangler OAuth session — simplest path:

bash
wrangler whoami

If OAuth is unavailable, use an API token instead:

bash
export CLOUDFLARE_API_TOKEN="$R2_API_KEY"

If the user belongs to multiple accounts, always set CLOUDFLARE_ACCOUNT_ID explicitly; otherwise bucket list / object put may default to the wrong account and fail with code: 10042 — Please enable R2 through the Cloudflare Dashboard, which actually means "this account has no R2, try another account".

Finding the Right Account

wrangler whoami prints an account table. For each account id, list buckets until the target bucket is found:

bash
for acct in <id1> <id2> <id3>; do
  echo "=== $acct ==="
  CLOUDFLARE_ACCOUNT_ID="$acct" wrangler r2 bucket list 2>&1 | grep -E "^name:|ERROR" | head -20
done

Cache the resolved CLOUDFLARE_ACCOUNT_ID for the remaining commands.

Single-File Upload

bash
CLOUDFLARE_ACCOUNT_ID="$ACCOUNT_ID" \
  wrangler r2 object put "$BUCKET/${KEY_PREFIX}<name>.webp" \
    --file="/path/to/local.webp" \
    --content-type="image/webp" \
    --remote

Flags that matter:

  • --remoterequired. Without it, the write goes to the local simulator, not production.
  • --content-type — set explicitly. Default guessing is unreliable and bad MIME breaks CDN / browsers.
  • Target is a single positional BUCKET/KEY string (no space between bucket and key).

Batch Upload (Directory)

bash
cd "$SRC_DIR" && for f in *.webp; do
  echo "--- $f ---"
  CLOUDFLARE_ACCOUNT_ID="$ACCOUNT_ID" \
    wrangler r2 object put "$BUCKET/${KEY_PREFIX}${f}" \
      --file="$f" \
      --content-type="image/webp" \
      --remote 2>&1 | grep -E 'Creating|error|ERROR' | head -3
done

For mixed MIME types, resolve per-file:

bash
mime_of() {
  case "$1" in
    *.webp) echo "image/webp" ;;
    *.png)  echo "image/png"  ;;
    *.jpg|*.jpeg) echo "image/jpeg" ;;
    *.svg)  echo "image/svg+xml" ;;
    *.json) echo "application/json" ;;
    *.html) echo "text/html; charset=utf-8" ;;
    *.txt|*.md) echo "text/plain; charset=utf-8" ;;
    *)      echo "application/octet-stream" ;;
  esac
}

Verification

Never claim success based on wrangler output alone. Run an HTTP HEAD against the public domain for every uploaded key:

bash
for f in "$SRC_DIR"/*.webp; do
  name=$(basename "$f")
  code=$(curl -sI -o /dev/null -w '%{http_code}' \
    "https://${PUBLIC_DOMAIN}/${KEY_PREFIX}${name}")
  printf "%-40s %s\n" "$name" "$code"
done

All lines must show 200. A 404 means the key path or bucket binding is wrong; a 403 means the custom domain is not bound to this bucket.

Common Mistakes

MistakeSymptomFix
Omitting --remoteUpload "succeeds" but public URL 404sRe-upload with --remote
Wrong accountPlease enable R2 through the Cloudflare Dashboard [code: 10042]Set CLOUDFLARE_ACCOUNT_ID to the account that actually owns the bucket
Missing --content-typeBrowser downloads instead of rendering; image shows as broken in <img>Always pass explicit MIME
Leading slash in keyCreates literal /prefix/... (double slash) pathsEnsure KEY_PREFIX does not start with /
Space in BUCKET/KEYCLI parses as two args, errorsPass as one single unbroken string
npx wrangler fails on pnpm-only setupsERROR Unknown option: 'yes'Use pnpm dlx wrangler@latest instead
Using local wrangler dev stateWrites invisible in production bucketAlways --remote for production writes

Rules

  • Prefer OAuth session over API token when both are available.
  • Always verify at least one URL per batch through the public domain before reporting completion.
  • Do not delete previous-generation objects immediately after updating DB records; keep a rollback window.
  • Never paste R2_API_KEY or CLOUDFLARE_API_TOKEN values into commit logs, commit messages, or PR descriptions.
  • Do not mix --remote and non-remote calls in the same batch.

Reporting Output

Preferred structured summary after a batch:

filesizekeystatus
emo.webp18.3 KBmx-space/topics/emo.webp200
............

Always list the fully-qualified public URLs at the end so the caller can paste them directly into downstream config or DB updates.

Frequently asked questions

What does the Cloudflare R2 Upload AI skill do?

Use when uploading one or many files to a Cloudflare R2 bucket and returning public URLs via a bound custom domain. Covers wrangler CLI and the REST API (Cloudflare API token) paths, batched uploads, MIME handling, correct account selection for multi-account setups, and post-upload public-URL verification. Triggers on tasks like "upload these images to R2", "push assets to the uploads bucket", "put files under <prefix>/ on R2".

Why use Cloudflare R2 Upload on TypingMind?

Because you install it once and use it with any model. Cloudflare R2 Upload is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Cloudflare R2 Upload in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Innei/SKILL/tree/main/skills/infrastructure/cloudflare-r2-upload. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Cloudflare R2 Upload?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Cloudflare R2 Upload?

As many as you like. As long as a model supports skills, you can use Cloudflare R2 Upload with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Cloudflare R2 Upload AI skill free?

It is published on GitHub by Innei. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇