| Crates.io | r2-uploader |
| lib.rs | r2-uploader |
| version | 0.3.0 |
| created_at | 2025-06-08 13:36:47.571679+00 |
| updated_at | 2025-06-11 06:04:43.23157+00 |
| description | A CLI tool for uploading compiled binaries to Cloudflare R2 storage |
| homepage | https://elsoul.nl/ |
| repository | https://github.com/ValidatorsDAO/solana-stream |
| max_upload_size | |
| id | 1704883 |
| size | 85,326 |
A CLI tool for uploading compiled binaries to Cloudflare R2 storage and managing Cloudflare cache.
This tool provides two main functionalities:
The upload feature stores binaries in both versioned and latest paths for easy access.
Install the tool using Cargo:
cargo install r2-uploader
This will install the r2 command globally on your system.
# Cloudflare R2 bucket name (required)
export CLOUDFLARE_R2_BUCKET="your_bucket_name"
# Cloudflare account ID (required)
export CLOUDFLARE_ACCOUNT_ID="your_account_id"
# Authentication method: API token or API key + email
# Method 1: API token (recommended)
export CLOUDFLARE_API_TOKEN="your_api_token"
# Method 2: API key + email
export CLOUDFLARE_API_KEY="your_api_key"
export CLOUDFLARE_EMAIL="your_email@example.com"
# Cloudflare zone ID (required for cache purging)
export CLOUDFLARE_ZONE_ID="your_zone_id"
# Cache purge authentication
export CLOUDFLARE_PURGE_EMAIL="your_email@example.com"
export CLOUDFLARE_PURGE_API_TOKEN="your_purge_api_token"
Upload compiled binaries to Cloudflare R2 storage.
Basic Usage:
# Upload binary with auto-detected version from Cargo.toml
r2 upload --name {app_name}
# Upload binary with specific version
r2 upload --name {app_name} --binary-version 0.3.0
Advanced Options:
# Upload binary from a specific file path
r2 upload --name {app_name} --binary-version 0.3.0 --file-path /path/to/custom/binary
# Upload binary from a different target directory
r2 upload --name {app_name} --binary-version 0.3.0 --target-dir ./target/debug
Upload Options:
| Option | Description | Required | Default Value |
|---|---|---|---|
--name |
Name of the binary to upload | Yes | - |
--binary-version |
Version of the binary | No | Auto-detected |
--file-path |
Custom file path to upload | No | - |
--target-dir |
Target directory to search for the binary | No | ./target/release |
Purge Cloudflare cache for specified URLs.
# Purge cache for multiple URLs
r2 purge --files https://example.com/file1.bin,https://example.com/file2.bin
# Purge cache for a single URL
r2 purge -f https://example.com/app.bin
Purge Options:
| Option | Description | Required |
|---|---|---|
--files |
Comma-separated list of URLs | Yes |
-f |
Short form of --files |
Yes |
Get help for any command:
# General help
r2 --help
# Upload command help
r2 upload --help
# Purge command help
r2 purge --help
bin/{name}/{version}/{name}bin/latest/{name}Uploaded binaries are stored with the following structure:
{bucket_name}/
└── bin/
├── {binary_name}/
│ └── {version}/
│ └── {binary_name}
└── latest/
└── {binary_name}
Example:
{bucket_name}/bin/my-app/0.3.0/my-app{bucket_name}/bin/latest/my-app# Set environment variables
export CLOUDFLARE_ACCOUNT_ID="your_account_id"
export CLOUDFLARE_API_TOKEN="your_api_token"
# Build your binary
cargo build --release
# Upload to R2 (version auto-detected from Cargo.toml)
r2 upload --name my-awesome-app
# Upload with specific version
r2 upload --name my-awesome-app --binary-version 1.0.0
# Set cache purge environment variables
export CLOUDFLARE_ZONE_ID="your_zone_id"
export CLOUDFLARE_PURGE_EMAIL="your_email@example.com"
export CLOUDFLARE_PURGE_API_TOKEN="your_purge_token"
# Purge cache for updated binaries
r2 purge --files https://cdn.example.com/bin/latest/my-app,https://cdn.example.com/bin/my-app/1.0.0/my-app