R2 Uploader
A CLI tool for uploading compiled binaries to Cloudflare R2 storage.
Overview
This tool is a simple CLI tool for uploading compiled Rust binaries to Cloudflare R2 storage. It uploads binaries to the appropriate location in the R2 bucket using the specified binary name and version.
Installation
Install the tool using Cargo:
This will install the r2 command globally on your system.
Usage
Required Environment Variables
Before using this tool, you need to set the following environment variables:
# Cloudflare account ID (required)
# Authentication method: API token or API key + email
# Method 1: API token (recommended)
# Method 2: API key + email
Command Examples
Basic Usage
# Upload {app_name} binary from target/release directory as version 0.3.0
Auto-detect Version from Cargo.toml
# Upload binary and auto-detect version from Cargo.toml
Specify Custom File Path
# Upload binary from a specific file path
Specify Custom Target Directory
# Upload binary from a different target directory
Options
| Option | Description | Required | Default Value |
|---|---|---|---|
--name |
Name of the binary to upload | Yes | - |
--binary-version |
Version of the binary | Yes | - |
--file-path |
Custom file path to upload | No | - |
--target-dir |
Target directory to search for the binary | No | ./target/release |
How It Works
- Reads the binary file from the specified path or target directory
- Uses the Cloudflare R2 API to upload the file with the specified name and version
- The upload destination path format is
bin/{version}/{name}
R2 Bucket Structure
Uploaded binaries are stored with the following structure:
{bucket_name}/
└── bin/
└── {version}/
└── {name}
Example: {bucket_name}/bin/0.3.0/{app_name}