Skip to content

Add R2 example - #81

Open
adewale wants to merge 3 commits into
cloudflare:mainfrom
adewale:add-r2-example
Open

Add R2 example#81
adewale wants to merge 3 commits into
cloudflare:mainfrom
adewale:add-r2-example

Conversation

@adewale

@adewale adewale commented May 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a Python Workers example for core Cloudflare R2 Workers API operations.

The example demonstrates:

  • object upload/download with put(), get(), and head()
  • direct request ReadableStream uploads to R2
  • direct R2 ReadableStream responses without copying large objects through Python memory
  • range reads
  • HTTP metadata and custom metadata
  • conditional read/write headers
  • checksum and storage class options
  • listing with prefix, limit, cursor, delimiter, and include
  • single-key and batch deletes
  • multipart upload create/upload/complete/abort using ?key= so keys with slashes work
  • shared large-file fixture routes for future examples

Dependency

Depends on #79.

This PR assumes #79 adds 16-sync-http-clients, so this example is numbered 17-r2. Until #79 merges, this PR's diff may include the preceding sync HTTP example commit as part of the branch history.

Tests

python3 -m py_compile 17-r2/src/entry.py
uv run pytest tests/test_examples.py::test_17_r2 -q
uv run ruff check 17-r2 tests/test_examples.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant