Cloudflare R2 icon

Cloudflare R2

Store and retrieve objects from Cloudflare R2

Overview

This node integrates with Cloudflare R2, a scalable object storage service compatible with the S3 API. Specifically, the "Bucket" resource with the "Get Info" operation allows users to retrieve metadata about a specific R2 bucket, such as its name and the count of keys (objects) it contains.

Common scenarios for this node include:

  • Verifying the existence and basic details of an R2 bucket before performing further operations.
  • Monitoring bucket usage by checking the number of stored objects.
  • Integrating bucket information retrieval into automated workflows for cloud storage management.

Practical example:

  • A user wants to confirm that a bucket named "my-unique-bucket" exists and see how many objects it currently holds. This node fetches that info, enabling conditional logic in the workflow based on bucket contents.

Properties

Name Meaning
Bucket Name The globally unique name of the R2 bucket to get information about.

Output

The node outputs JSON data containing information about the specified bucket:

  • bucket: The bucket name.
  • keyCount: The number of keys (objects) in the bucket.

Example output JSON:

{
  "bucket": "my-unique-bucket",
  "keyCount": 42,
  "name": "my-unique-bucket"
}

No binary data is output by this operation.

Dependencies

  • Requires valid Cloudflare API credentials configured with "R2 S3-Compatible" authentication mode, including:
    • R2 Access Key ID
    • R2 Secret Access Key
    • Account ID
  • Uses AWS SDK for JavaScript v3 S3 client configured to communicate with Cloudflare R2 endpoints.
  • Node expects the Cloudflare API credential to provide these R2-compatible credentials.
  • Network access to the Cloudflare R2 endpoint URL corresponding to the account and jurisdiction.

Troubleshooting

Common Issues

  • Invalid or missing R2 credentials: The node throws an error if the R2 Access Key ID, Secret Access Key, or endpoint URL is missing or invalid. Ensure credentials are correctly set and the authentication mode is "R2 S3-Compatible".
  • Bucket not found: If the specified bucket does not exist, the request will fail. Verify the bucket name is correct and exists in your Cloudflare account.
  • Network connectivity issues: Failure to reach the Cloudflare R2 endpoint due to network restrictions or incorrect endpoint configuration.
  • Permission errors: Insufficient permissions on the API token or keys to list or get bucket info.

Error Messages

  • "R2 credentials are missing or invalid. Please check your Cloudflare API credentials configuration."
    Indicates missing or incomplete R2 credentials in the node's credential settings.

  • HTTP errors from the R2 API (e.g., 404 Not Found) indicate the bucket does not exist or is inaccessible.

  • "Cannot delete bucket '...' : Bucket must be completely empty before deletion."
    (Related to delete operation) Means the bucket still contains objects; all must be removed before deletion.

Resolution Tips

  • Double-check the Cloudflare API credentials and ensure the "R2 S3-Compatible" mode is selected.
  • Confirm the bucket name is exactly correct and globally unique.
  • Check network/firewall settings to allow outbound requests to the R2 endpoint.
  • Review API token permissions in the Cloudflare dashboard.

Links and References


Summary of execute() method logic for Resource "Bucket" and Operation "Get Info"

  • Retrieves the bucket name parameter.
  • Obtains R2 credentials from the configured Cloudflare API credential.
  • Validates presence of required R2 credentials (access key, secret key, endpoint).
  • Constructs an HTTP GET request to the R2 endpoint with path /{bucketName}?list-type=2&max-keys=1.
  • Signs the request using AWS Signature V4 with the R2 credentials.
  • Sends the request and receives XML response listing objects (limited to 1).
  • Parses the XML response to extract bucket name and key count.
  • Returns this info as JSON output.

This operation uses the AWS S3-compatible API to query bucket contents metadata from Cloudflare R2.

Discussion