Complete command-line interface documentation for r2put.
r2put --file <path> --bucket <name> [--key <key>] [--region <region>] [--help]Or using short flags:
r2put -f <path> -b <name> [-k <key>] [-r <region>] [-h]--file, -f <path>Path to file to upload. Can be relative or absolute path.
r2put --file ./data.bin --bucket my-bucket
r2put --file /home/user/data.bin --bucket my-bucket
r2put --file "./my file.bin" --bucket my-bucketValidation:
--bucket, -b <name>Target R2 bucket name.
r2put --file ./data.bin --bucket production-v4
r2put -f ./image.png -b assetsValidation:
--key, -k <key>Custom object key for the uploaded file.
--file pathr2put --file ./local-image.png --bucket assets --key images/hero.png
r2put -f ./data.bin -b my-bucket -k "backups/$(date +%Y%m%d).bin"Behavior:
--file path--region, -r <region>Region hint for display purposes.
"WNAM"r2put --file ./backup.tar.gz --bucket backups --region ENAM
r2put -f ./data.bin -b my-bucket -r APACBehavior:
WNAM, ENAM, APAC, EEUR, WEUR--help, -hShow help message and exit.
r2put --help
r2put -hAll environment variables are required:
CLOUDFLARE_ACCOUNT_ID # Your Cloudflare Account ID
R2_ACCESS_KEY_ID # R2 API Access Key ID
R2_SECRET_ACCESS_KEY # R2 API Secret Access KeyValidation:
0 - Upload completed successfully1 - Error occurred (missing arguments, file not found, missing credentials, upload failed, etc.)r2put --file ./data.bin --bucket production-v4r2put -f ./local-image.png -b assets -k images/hero.pngr2put --file ./backup.tar.gz --bucket backups --region ENAM# Set environment variables
export CLOUDFLARE_ACCOUNT_ID="abc123..."
export R2_ACCESS_KEY_ID="xyz789..."
export R2_SECRET_ACCESS_KEY="secret..."
# Upload file
r2put --file ./data.bin --bucket production-v4
# Upload with custom key
r2put -f ./image.png -b assets -k images/hero.png -r ENAMThe CLI validates all arguments before processing:
--file must be provided and point to an existing file (not a directory)--bucket must be provided and be a valid R2 bucket name--key is optional; if not provided, uses filename from --file path--region is optional; used only for display purposesCommon error messages:
ERROR: Missing required argument: --fileERROR: File not found: /path/to/fileERROR: Not a file: /path/to/directoryERROR: Missing CLOUDFLARE_ACCOUNT_ID environment variableERROR: Missing R2_ACCESS_KEY_ID environment variableERROR: Missing R2_SECRET_ACCESS_KEY environment variableSee Error Handling Reference for complete error documentation.