feat(cloudflare): add R2 multipart upload with streaming and S3 credentials support#1167
Open
austinm911 wants to merge 6 commits intoalchemy-run:mainfrom
Open
feat(cloudflare): add R2 multipart upload with streaming and S3 credentials support#1167austinm911 wants to merge 6 commits intoalchemy-run:mainfrom
austinm911 wants to merge 6 commits intoalchemy-run:mainfrom
Conversation
…art uploads - Introduced new properties `accessKeyId`, `secretAccessKey`, and `sessionToken` in CloudflareApiOptions for S3-compatible R2 operations. - Implemented R2S3Client to manage S3 interactions, including multipart upload handling. - Updated R2Bucket resource to utilize the new S3 client for multipart upload operations. - Enhanced documentation to reflect the new credentials requirements and multipart upload capabilities.
Enhances R2Bucket multipart upload functionality with: - Node.js Readable stream support for efficient memory usage - Optional size parameter to enable streaming without buffering - Miniflare compatibility for local development testing - Comprehensive Worker example showing API upload pattern - Type guards for duck-typed Headers, Blob, and ReadableStream This allows uploading large files (100MB+) from Workers without loading the entire file into memory, essential for production workloads. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
commit: |
austinm911
commented
Oct 22, 2025
- Update return types to match official R2 API (R2Object, R2ObjectBody) - Add support for bulk delete operations (multiple keys) - Improve multipart upload handling with Node.js Readable stream support - Add retry logic for 404 errors in state store (bucket propagation) - Update tests to match new return types Note: Some tests are failing/timeout due to remote API issues (not code bugs): - bucket delete multiple keys (timeout) - bucket with data catalog (timeout) - bucket put operation with headers (404 error) These appear to be flaky Cloudflare API responses rather than implementation issues.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive multipart upload support to the R2Bucket resource, enabling efficient handling of large files (100MB+) with streaming capabilities and S3-compatible credentials.
Features
S3-Compatible Credentials Support
accessKeyId,secretAccessKey, andsessionTokenproperties toCloudflareApiOptionsR2S3Clientfor S3-compatible multipart upload operationsStreaming Support for Multipart Uploads
Use Cases
Code Example
Changes
alchemy/src/cloudflare/bucket.ts: Enhanced with multipart upload streaming supportalchemy/src/cloudflare/r2-s3-client.ts: New S3 client implementationalchemy/src/cloudflare/api.ts: Added S3 credential propertiesalchemy/test/cloudflare/bucket.test.ts: Comprehensive test coveragealchemy-web/content/docs/providers/cloudflare/bucket.md: Updated documentationTesting
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com