cloudflare-r2-object-storage
Skill2 starsChanged 28 days agoApache-2.0View on GitHub
Architects, configures, and integrates Cloudflare R2 zero-egress object storage using S3-compatible APIs, pre-signed upload URLs, multipart streaming, and edge CDN distribution.
- Reads credentials
In this repository108 other files it gives its agents.
- AGENTS.mdAGENTS.md
- everything-gemini-maintainerSkill
- adversarial-fuzz-generatorSkill
- agent-evalsSkill
- ai-first-engineeringSkill
- alloydb-omni-vectorSkill
- apache-kafka-streamsSkill
- api-craftsmanSkill
- architecture-designerSkill
- argon-3d-game-engineSkill
- argon-3d-scene-architectSkill
- argon-procedural-asset-generatorSkill
- argon-visual-critique-loopSkill
- argo-workflowsSkill
- autonomous-incident-healerSkill
- axum-web-serviceSkill
- bigquery-vector-searchSkill
- browser-qa-testerSkill
- chromadb-vector-storeSkill
- cilium-ebpf-networkingSkill
- clickhouse-analyticsSkill
- cloud-deploy-canarySkill
- cloudflare-workersSkill
- cloud-run-agentsSkill
- context-cachingSkill
- context-distillation-compressorSkill
- context-warmerSkill
- continuous-learningSkill
- cost-oracle-finopsSkill
- cross-repo-swarm-syncSkill
- cve-remediation-orchestratorSkill
- database-architectSkill
- dataproc-spark-analyticsSkill
- dbt-transformationSkill
- debezium-cdcSkill
- devops-pipelineSkill
- distributed-rate-limitingSkill
- docker-compose-orchestratorSkill
- duckdb-local-olapSkill
- dynamic-thinking-allocationSkill
- ebpf-microvm-sandboxSkill
- ebpf-sandbox-enforcerSkill
- elephant-goldfish-modelSkill
- envoy-ai-gatewaySkill
- ephemeral-swarm-orchestratorSkill
- fastapi-productionSkill
- fullstack-nextjsSkill
- game-audio-synthesizerSkill
- game-studioSkill
- gemini-function-callingSkill
- gemini-groundingSkill
- gemini-live-audio-transcriberSkill
- gemini-live-multimodalSkill
- gemini-live-screen-visionSkill
- gemini-multimodalSkill
- genetic-prompt-cross-pollinatorSkill
- git-craftsmanSkill
- github-opsSkill
- google-axSkill
- google-flow-orchestratorSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 140
Bucket Region: Always set region to auto in AWS S3 SDK clients.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Cloudflare R2 Object Storage & Edge Distribution
This skill guides the implementation of zero-egress fee object storage using Cloudflare R2 with S3-compatible APIs, pre-signed URLs, multipart uploads, and edge CDN distribution.
⚡ Architectural Comparison: R2 vs Standard S3
| Feature | Cloudflare R2 | Standard AWS S3 |
| Data Egress Fees | $0.00 / GB (Free) | ~$0.09 / GB |
| API Compatibility | Full S3 API v4 signature | Native AWS S3 |
| Edge Integration | Native Cloudflare Workers & CDN | CloudFront integration required |
| Storage Pricing | $0.015 / GB-month | $0.023 / GB-month |
| Global Replication | Automatic across edge locations | Cross-Region Replication (CRR) billed |
🛠️ TypeScript S3 Client Configuration (@aws-sdk/client-s3)
R2 endpoints use account-specific URLs with AWS Signature Version 4:
import { S3Client, PutObjectCommand, GetObjectCommand } from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
const ACCOUNT_ID = process.env.CLOUDFLARE_ACCOUNT_ID!;
const R2_ACCESS_KEY_ID = process.env.R2_ACCESS_KEY_ID!;
const R2_SECRET_ACCESS_KEY = process.env.R2_SECRET_ACCESS_KEY!;
export const r2Client = new S3Client({
region: 'auto',
endpoint: `https://${ACCOUNT_ID}.r2.cloudflarestorage.com`,
credentials: {
accessKeyId: R2_ACCESS_KEY_ID,
secretAccessKey: R2_SECRET_ACCESS_KEY,
},
});📤 Pre-Signed URLs for Direct Browser Uploads
Prevent API server bottlenecking by generating short-lived pre-signed upload URLs:
export async function generateUploadUrl(key: string, contentType: string, expiresInSeconds = 300) {
const command = new PutObjectCommand({
Bucket: 'enterprise-artifacts',
Key: key,
ContentType: contentType,
});
const uploadUrl = await getSignedUrl(r2Client, command, { expiresIn: expiresInSeconds });
return {
uploadUrl,
key,
publicUrl: `https://cdn.example.com/${key}`,
};
}📦 High-Throughput Multipart Uploads (Node.js / Python)
For files exceeding 100MB, use parallel multipart uploads with the Upload helper:
import { Upload } from '@aws-sdk/lib-storage';
import fs from 'node:fs';
export async function uploadLargeArchive(filePath: string, destinationKey: string) {
const fileStream = fs.createReadStream(filePath);
const parallelUpload = new Upload({
client: r2Client,
params: {
Bucket: 'enterprise-artifacts',
Key: destinationKey,
Body: fileStream,
ContentType: 'application/octet-stream',
},
queueSize: 4, // 4 concurrent part uploads
partSize: 10 * 1024 * 1024, // 10MB chunk size
leavePartsOnError: false,
});
parallelUpload.on('httpUploadProgress', (progress) => {
console.log(`Uploaded ${progress.loaded} of ${progress.total} bytes`);
});
return await parallelUpload.done();
}🌐 Custom Domain & Cloudflare CDN Caching Rule
Expose R2 buckets through a custom domain with edge cache headers:
// Cloudflare Worker Edge Proxy
export default {
async fetch(request, env) {
const url = new URL(request.url);
const key = url.pathname.slice(1);
if (request.method !== 'GET') {
return new Response('Method Not Allowed', { status: 405 });
}
const object = await env.MY_R2_BUCKET.get(key);
if (!object) {
return new Response('Not Found', { status: 404 });
}
const headers = new Headers();
object.writeHttpMetadata(headers);
headers.set('etag', object.httpEtag);
headers.set('Cache-Control', 'public, max-age=31536000, immutable');
return new Response(object.body, { headers });
},
};📋 Architectural Rules & Best Practices
- Bucket Region: Always set region to
autoin AWS S3 SDK clients; R2 automatically routes storage to the lowest-latency regional cluster. - CORS Headers: Set permissive CORS rules (
AllowedOrigins,AllowedMethods: ["PUT", "GET"]) on the R2 bucket for direct browser pre-signed uploads. - Multipart Cleanup: Configure bucket lifecycle rules to automatically abort incomplete multipart uploads after 7 days (
AbortIncompleteMultipartUpload). - Zero-Egress Strategy: Route public media and file downloads through Cloudflare Custom Domains or Workers to benefit from zero bandwidth charges.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

