Infrastructure: Which S3-compatible client should be used for Cloudflare R2 ...
Documentation for Sessions
📝 Infrastructure: Which S3-compatible client should be used for Cloudflare R2 ...
Date: 2026-03-10
Time: 17:58:43 UTC
Session: gspace1-198.3
Agent: backend
Confidence: 95%
Status: ✅ Documented
📋 Decision Context
Question:
Which S3-compatible client should be used for Cloudflare R2 integration?
Task: S198.1: Multimodal vision + Cloudflare R2 storage
🎯 Decision Made
Chosen:
@aws-sdk/client-s3 + @aws-sdk/s3-request-presigner — the standard AWS S3 SDK pointed at R2's S3-compatible endpoint.
Options Considered:
- @aws-sdk/client-s3 (S3-compatible)
- Cloudflare HTTP REST API via HttpService
- wrangler CLI commands from Node.js
💭 Reasoning
R2 adopted the S3 API specifically because it's a de facto industry standard. Using @aws-sdk/client-s3 means: (1) zero code changes to switch to AWS S3, DigitalOcean Spaces, MinIO, or Backblaze B2 — just change endpoint config; (2) built-in presigned URLs, multipart upload, streaming — no need to build these; (3) battle-tested library with strong TypeScript support; (4) 3MB dependency is irrelevant for a backend service. The alternative — Cloudflare's HTTP REST API via HttpService — would match the existing cloudflare-pages.service.ts pattern but locks us to a proprietary API surface. If Cloudflare changes their REST API or we move off R2, we'd rewrite. The S3 API is universal and permanent.
📁 Files Involved
libs/libs-api/r2-storage-core/src/lib/services/r2-storage.service.tspackage.json
🔗 Related
- Decision ID:
dev_1773165523509_twvxf0z - Session: 198
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation