<!-- SPDX-License-Identifier: MIT -->
<!-- SPDX-FileCopyrightText: 2025-2026 Marcus Quinn -->

# Cloudflare R2 Object Storage

Use R2 for assets, uploads, backups, and dataset blobs when you want S3 compatibility without egress fees.

## Quick Reference

| Capability | Notes |
|------------|-------|
| API surface | Workers binding and S3-compatible REST API |
| Consistency | Strong consistency for writes and deletes |
| Cost model | Zero egress fees; Infrequent Access adds retrieval and minimum-duration costs |
| Storage classes | `Standard` (frequent access); `InfrequentAccess` (lower cost, 30-day min + retrieval fees) |
| Encryption | SSE-C supported |

## Quick Start

```bash
wrangler r2 bucket create my-bucket --location=enam
wrangler r2 object put my-bucket/file.txt --file=./local.txt
```

```typescript
await env.MY_BUCKET.put(key, data, {
  httpMetadata: { contentType: 'image/jpeg' },
});

const object = await env.MY_BUCKET.get(key);
if (object) return new Response(object.body);
```

## Core Operations

| Method | Use |
|--------|-----|
| `put(key, value, options?)` | Upload object data and metadata |
| `get(key, options?)` | Read object body or conditional result |
| `head(key)` | Read metadata without the body |
| `delete(keys)` | Delete one key or a batch |
| `list(options?)` | Page through objects by prefix/cursor |

## Read Next

- [r2-patterns.md](./r2-patterns.md) - streaming downloads, conditional requests, multipart upload, public buckets
- [r2-gotchas.md](./r2-gotchas.md) - list truncation, `httpEtag`, checksum limits, multipart rules
- [workers.md](./workers.md) - request handling around R2 bindings
- [kv.md](./kv.md) - metadata and lookup records for R2 objects
- [d1.md](./d1.md) - relational records pointing at R2 keys or URLs
- [queues.md](./queues.md) - async processing for upload and ingest pipelines
