cloudflare-r2
Complete knowledge domain for Cloudflare R2 - S3-compatible object storage on Cloudflare's edge network. Use when: creating R2 buckets, uploading files to R2, downloading objects, configuring R2 bindings, setting up CORS, generating presigned URLs, multipart uploads, storing images/assets, managing object metadata, or encountering "R2_ERROR", CORS errors, presigned URL failures, multipart upload issues, or storage quota errors. Keywords: r2, r2 storage, cloudflare r2, r2 bucket, r2 upload, r2 download, r2 binding, object storage, s3 compatible, r2 cors, presigned urls, multipart upload, r2 api, r2 workers, file upload, asset storage, R2_ERROR, R2Bucket, r2 metadata, custom metadata, http metadata, content-type, cache-control, aws4fetch, s3 client, bulk delete, r2 list, storage class
What this skill does
# Cloudflare R2 Object Storage **Status**: Production Ready ✅ **Last Updated**: 2025-10-21 **Dependencies**: cloudflare-worker-base (for Worker setup) **Latest Versions**: [email protected], @cloudflare/[email protected], [email protected] --- ## Quick Start (5 Minutes) ### 1. Create R2 Bucket ```bash # Via Wrangler CLI (recommended) npx wrangler r2 bucket create my-bucket # Or via Cloudflare Dashboard # https://dash.cloudflare.com → R2 Object Storage → Create bucket ``` **Bucket Naming Rules:** - 3-63 characters - Lowercase letters, numbers, hyphens only - Must start/end with letter or number - Globally unique within your account ### 2. Configure R2 Binding Add to your `wrangler.jsonc`: ```jsonc { "name": "my-worker", "main": "src/index.ts", "compatibility_date": "2025-10-11", "r2_buckets": [ { "binding": "MY_BUCKET", // Available as env.MY_BUCKET in your Worker "bucket_name": "my-bucket", // Name from wrangler r2 bucket create "preview_bucket_name": "my-bucket-preview" // Optional: separate bucket for dev } ] } ``` **CRITICAL:** - `binding` is how you access the bucket in code (`env.MY_BUCKET`) - `bucket_name` is the actual R2 bucket name - `preview_bucket_name` is optional but recommended for separate dev/prod data ### 3. Basic Upload/Download ```typescript // src/index.ts 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(); try { 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, etag: object.etag, }); } catch (error: any) { console.error('R2 Upload Error:', error.message); return c.json({ error: 'Upload failed' }, 500); } }); // Download file app.get('/download/:filename', async (c) => { const filename = c.req.param('filename'); try { const object = await c.env.MY_BUCKET.get(filename); if (!object) { return c.json({ error: 'File not found' }, 404); } return new Response(object.body, { headers: { 'Content-Type': object.httpMetadata?.contentType || 'application/octet-stream', 'ETag': object.httpEtag, 'Cache-Control': object.httpMetadata?.cacheControl || 'public, max-age=3600', }, }); } catch (error: any) { console.error('R2 Download Error:', error.message); return c.json({ error: 'Download failed' }, 500); } }); export default app; ``` ### 4. Deploy and Test ```bash # Deploy npx wrangler deploy # Test upload curl -X PUT https://my-worker.workers.dev/upload/test.txt \ -H "Content-Type: text/plain" \ -d "Hello, R2!" # Test download curl https://my-worker.workers.dev/download/test.txt ``` --- ## R2 Workers API ### Type Definitions ```typescript // Add to env.d.ts or worker-configuration.d.ts interface Env { MY_BUCKET: R2Bucket; // ... other bindings } // For Hono type Bindings = { MY_BUCKET: R2Bucket; }; const app = new Hono<{ Bindings: Bindings }>(); ``` ### put() - Upload Objects **Signature:** ```typescript put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | Blob, options?: R2PutOptions): Promise<R2Object | null> ``` **Basic Usage:** ```typescript // Upload from request body await env.MY_BUCKET.put('path/to/file.txt', request.body); // Upload string await env.MY_BUCKET.put('config.json', JSON.stringify({ foo: 'bar' })); // Upload ArrayBuffer await env.MY_BUCKET.put('image.png', await file.arrayBuffer()); ``` **With Metadata:** ```typescript const object = await env.MY_BUCKET.put('document.pdf', fileData, { httpMetadata: { contentType: 'application/pdf', contentLanguage: 'en-US', contentDisposition: 'attachment; filename="report.pdf"', contentEncoding: 'gzip', cacheControl: 'public, max-age=86400', }, customMetadata: { userId: '12345', uploadDate: new Date().toISOString(), version: '1.0', }, }); ``` **Conditional Uploads (Prevent Overwrites):** ```typescript // Only upload if file doesn't exist const object = await env.MY_BUCKET.put('file.txt', data, { onlyIf: { uploadedBefore: new Date('2020-01-01'), // Any date before R2 existed }, }); if (!object) { // File already exists, upload prevented return c.json({ error: 'File already exists' }, 409); } // Only upload if etag matches (update specific version) const object = await env.MY_BUCKET.put('file.txt', data, { onlyIf: { etagMatches: existingEtag, }, }); ``` **With Checksums:** ```typescript // R2 will verify the checksum const md5Hash = await crypto.subtle.digest('MD5', fileData); await env.MY_BUCKET.put('file.txt', fileData, { md5: md5Hash, }); ``` ### get() - Download Objects **Signature:** ```typescript get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null> ``` **Basic Usage:** ```typescript // Get full object const object = await env.MY_BUCKET.get('file.txt'); if (!object) { return c.json({ error: 'Not found' }, 404); } // Return as response return new Response(object.body, { headers: { 'Content-Type': object.httpMetadata?.contentType || 'application/octet-stream', 'ETag': object.httpEtag, }, }); ``` **Read as Different Formats:** ```typescript const object = await env.MY_BUCKET.get('data.json'); if (object) { const text = await object.text(); // As string const json = await object.json(); // As JSON object const buffer = await object.arrayBuffer(); // As ArrayBuffer const blob = await object.blob(); // As Blob } ``` **Range Requests (Partial Downloads):** ```typescript // Get first 1MB of file const object = await env.MY_BUCKET.get('large-file.mp4', { range: { offset: 0, length: 1024 * 1024 }, }); // Get bytes 100-200 const object = await env.MY_BUCKET.get('file.bin', { range: { offset: 100, length: 100 }, }); // Get from offset to end const object = await env.MY_BUCKET.get('file.bin', { range: { offset: 1000 }, }); ``` **Conditional Downloads:** ```typescript // Only download if etag matches const object = await env.MY_BUCKET.get('file.txt', { onlyIf: { etagMatches: cachedEtag, }, }); if (!object) { // Etag didn't match, file was modified return c.json({ error: 'File changed' }, 412); } ``` ### head() - Get Metadata Only **Signature:** ```typescript head(key: string): Promise<R2Object | null> ``` **Usage:** ```typescript // Get object metadata without downloading body const object = await env.MY_BUCKET.head('file.txt'); if (object) { console.log({ key: object.key, size: object.size, etag: object.etag, uploaded: object.uploaded, contentType: object.httpMetadata?.contentType, customMetadata: object.customMetadata, }); } ``` **Use Cases:** - Check if file exists - Get file size before downloading - Check last modified date - Validate etag for caching ### delete() - Delete Objects **Signature:** ```typescript delete(key: string | string[]): Promise<void> ``` **Single Delete:** ```typescript // Delete single object await env.MY_BUCKET.delete('file.txt'); // No error if file doesn't exist (idempotent) ``` **Bulk Delete (Up to 1000 keys):** ```typescript // Delete multiple objects at once const keysToDelete = [ 'old-file-1.txt', 'old-file-2.txt', 'temp/cache-data.json', ]; await env.MY_BUCKET.delete(keysToDelete); // Much faster than individual deletes ``` **Delete with Confirmation:** ```typescript app.delete('/files/:filename', async (c) => { const filename = c.req.param('filename'); // Check if exists first const exists = await c.env.MY_BUCKET.head(filename); if (!exists) { return c.json({ error: 'F
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.