Skip to main content

Wrapper around commonly used boto3 functions in Cloudflare R2 API.

Project description

cloudflare-r2

Github CI

Small Python and CLI wrapper for Cloudflare R2's S3-compatible API.

Use it when you want a reusable r2 command for directory transfers, dotenv configuration, and bucket access checks across apps.

Install

uv add cloudflare-r2

Configure

Create a .env file:

R2_ACCOUNT_ID=your-account-id
R2_BUCKET=your-bucket
R2_ACCESS_KEY_ID=your-token-key
R2_SECRET_ACCESS_KEY=your-token-secret
R2_REGION=auto
R2_PREFIX=

Then verify that credentials and bucket access work:

r2 doctor --env-file .env --show-bucket

Common Commands

Upload a local directory:

r2 upload-dir --source data --prefix "" --overwrite skip

Download a remote prefix:

r2 download-prefix --target data --prefix "" --preserve-key

Single-object compatibility commands are still available:

r2 upload --bucket test-bucket --src README.md --key README.md
r2 download --bucket test-bucket --key README.md

1Password

Generate a local dotenv file from item references:

op inject -i env.example -o .env
op run --env-file .env -- r2 doctor --show-bucket

Mounted 1Password .env files work the same way because the package reads normal environment variables and dotenv files.

App Integration

Delegate app-specific upload and download tasks to the package command:

download:
  uv run r2 download-prefix --target data

upload:
  uv run r2 upload-dir --source data

Full usage notes and API reference are published at justmars.github.io/cloudflare-r2.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloudflare_r2-0.0.6.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cloudflare_r2-0.0.6-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file cloudflare_r2-0.0.6.tar.gz.

File metadata

  • Download URL: cloudflare_r2-0.0.6.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cloudflare_r2-0.0.6.tar.gz
Algorithm Hash digest
SHA256 4ff48c83e46cfa2e52bb00a1bfa7cd87b36c81000be70b07b8b63f3d974ee360
MD5 155ddfd20a93571ffe618847cadb7879
BLAKE2b-256 0819eedd300493fd8d3b18b7d1b5ddb320a7f9ebc40d0b5000cba89d62475d82

See more details on using hashes here.

File details

Details for the file cloudflare_r2-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: cloudflare_r2-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cloudflare_r2-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 43464b10590ad59669ffe1362c7f75f4bdbe478ec01bb8aeeff10c95cc6d7bc7
MD5 dfd682829581eceb64c7395a4af5027d
BLAKE2b-256 579bcb262d1312fe368ab51f2bc52280def79717208a0d03af71b86ea9ca31df

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page