-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
r2Relating to R2Relating to R2
Description
Describe the solution
Summary
wrangler r2 object currently supports get, put, and delete but has no list subcommand. There is no way to list objects in an R2 bucket using the wrangler CLI.
Use case
Emptying an R2 bucket before deletion. wrangler r2 bucket delete fails on non-empty buckets, but there's no wrangler command to discover what's in the bucket. This forces users to fall back to the CF REST API or external tools (AWS CLI, rclone) just to list objects.
Current workaround
# List via CF REST API (paginated)
curl -s "https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/r2/buckets/${BUCKET}/objects?per_page=100" \
-H "Authorization: Bearer ${API_TOKEN}" | jq -r '.result[].key'
# Then delete each object individually
wrangler r2 object delete "${BUCKET}/${KEY}" --remoteThis requires mixing CF API calls with wrangler commands and manually handling pagination cursors.
Proposed solution
# List all objects in a bucket
wrangler r2 object list <bucket> [--remote] [--prefix <prefix>] [--delimiter <delimiter>]
# With JSON output for scripting
wrangler r2 object list <bucket> --remote --jsonEnvironment
- wrangler 4.76.0
- macOS
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
r2Relating to R2Relating to R2
Type
Projects
Status
Other