cloudflare-r2

Cloudflare R2 object storage integration with upload, download, and management patterns.

View on GitHub
Author Jeremy Dawes
Namespace @jezweb/claude-skills
Category cloudflare
Version 1.0.0
Stars 79
Downloads 4
self.md verified
Table of content

Cloudflare R2 object storage integration with upload, download, and management patterns.

Installation

npx claude-plugins install @jezweb/claude-skills/cloudflare-r2

Contents

Folders: references, rules, templates

Files: README.md, SKILL.md

Documentation

Complete knowledge domain for Cloudflare R2 - S3-compatible object storage on Cloudflare’s global network.


Auto-Trigger Keywords

Primary Keywords

Secondary Keywords

Error-Based Keywords

Framework Integration Keywords


What This Skill Does

This skill provides complete R2 knowledge including:


Known Issues Prevented

IssueDescriptionPrevention
CORS errorsBrowser uploads failConfigure CORS before browser access
Binary downloadsFiles download as binary blobAlways set contentType on upload
Presigned URL securityURLs never expireSet X-Amz-Expires parameter
Multipart limitsUpload fails with large filesUse 5MB-100MB parts, max 10,000 parts
Bulk delete limitsDeleting >1000 keys failsChunk into batches of 1000
Metadata overflowCustom metadata exceeds 2KBKeep total metadata under 2KB

When to Use This Skill

✅ Use this skill when:

❌ When NOT to use:


Quick Example

import { Hono } from 'hono';

type Bindings = {
  MY_BUCKET: R2Bucket;
};

const app = new Hono<{ Bindings: Bindings }>();

// Upload file
app.put('/upload/:filename', async (c) => {
  const filename = c.req.param('filename');
  const body = await c.req.arrayBuffer();

  const object = await c.env.MY_BUCKET.put(filename, body, {
    httpMetadata: {
      contentType: c.req.header('content-type') || 'application/octet-stream',
    },
  });

  return c.json({
    success: true,
    key: object.key,
    size: object.size,
  });
});

// Download file
app.get('/download/:filename', async (c) => {
  const filename = c.req.param('filename');
  const object = await c.env.MY_BUCKET.get(filename);

  if (!object) {
    return c.json({ error: 'Not found' }, 404);
  }

  return new Response(object.body, {
    headers: {
      'Content-Type': object.httpMetadata?.contentType || 'application/octet-stream',
      'ETag': object.httpEtag,
    },
  });
});

export default app;

Token Efficiency


Files Included


Dependencies


Production Status

Production Ready

This skill is based on:


…(truncated)

Source

View on GitHub

Tags: cloudflare cloudflarer2storages3objectsfiles