npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

n8n-nodes-cloudflare-r2-storage

v0.3.0

Published

n8n community node for Cloudflare R2 object storage integration, featuring bucket management, object operations (upload/download/delete), multipart uploads, batch operations, CORS policies, and full AI Agent compatibility

Readme

n8n-nodes-cloudflare-r2

npm version License: MIT

An n8n community node for seamless integration with Cloudflare R2 Object Storage. Upload, download, manage files and buckets with zero egress fees. Includes batch operations, CORS management, and full AI Agent compatibility.

Table of Contents

Installation

Via n8n Community Nodes (Recommended)

  1. Go to SettingsCommunity Nodes in your n8n instance
  2. Enter n8n-nodes-cloudflare-r2-storage in the Package field
  3. Click Install
  4. Restart your n8n instance

Via npm

# Navigate to your n8n installation folder
cd ~/.n8n

# Install the package  
npm install n8n-nodes-cloudflare-r2-storage

# Restart n8n

Operations

🪣 Bucket Operations

  • Create - Create new R2 buckets with location hints
  • List - List all buckets in your account
  • Get Info - Get detailed bucket information
  • Delete - Remove empty buckets
  • CORS Management - Get, set, and delete CORS policies

📄 Object Operations

  • Upload - Upload files from binary data or text content
  • Download - Download files with automatic binary data handling
  • Delete - Remove objects from buckets
  • List - List objects with prefix filtering and pagination
  • Copy - Copy objects between buckets
  • Get Metadata - Retrieve object metadata without downloading

⚡ Batch Operations

  • Upload Multiple - Upload multiple files in one operation
  • Delete Multiple - Delete up to 1,000 objects at once
  • Download Multiple - Download multiple files efficiently

Credentials

You'll need a Cloudflare account with R2 enabled. This node requires two sets of credentials:

1. API Token (for bucket management)

  1. Go to Cloudflare Dashboard
  2. Click "Create Token""Custom token"
  3. Configure permissions:
    • Account: Cloudflare R2:Edit
    • Zone Resources: Include - All zones (if using custom domains)
  4. Copy the generated token

2. R2 Access Keys (for object operations)

  1. Go to your Cloudflare R2 Dashboard
  2. Select R2Manage R2 API Tokens
  3. Click "Create API Token"
  4. Configure:
    • Token Name: Choose a descriptive name (e.g., "n8n-r2-access")
    • Permissions: Select Object Read & Write (or appropriate level)
    • Bucket: Select specific buckets or allow all
  5. Click "Create API Token"
  6. Copy the Access Key ID and Secret Access Key (you won't see the secret again!)

Node Credentials Configuration

  • Account ID: Your Cloudflare Account ID (found in dashboard sidebar)
  • API Token: The token created in step 1 (for bucket operations)
  • Access Key ID: The R2 Access Key ID from step 2 (for object operations)
  • Secret Access Key: The R2 Secret Access Key from step 2 (for object operations)
  • API Endpoint: https://api.cloudflare.com/client/v4 (default)

Usage Examples

Basic File Upload

{
  "resource": "object",
  "operation": "upload", 
  "bucketName": "my-storage-bucket",
  "objectKey": "documents/report.pdf",
  "dataSource": "binaryData",
  "binaryPropertyName": "data",
  "contentType": "application/pdf"
}

List Objects with Filtering

{
  "resource": "object",
  "operation": "list",
  "bucketName": "my-storage-bucket", 
  "listOptions": {
    "prefix": "images/",
    "maxKeys": 100
  }
}

Batch Delete

{
  "resource": "batch",
  "operation": "deleteMultiple",
  "bucketName": "my-storage-bucket",
  "objectKeys": "old/file1.txt\nold/file2.jpg\ntemp/cache.json"
}

CORS Configuration

{
  "resource": "bucket", 
  "operation": "setCORS",
  "bucketName": "my-web-assets",
  "corsRules": {
    "rules": [
      {
        "allowedOrigins": "https://mywebsite.com,https://app.mywebsite.com",
        "allowedMethods": ["GET", "POST", "PUT"],
        "allowedHeaders": "Content-Type,Authorization",
        "maxAge": 3600
      }
    ]
  }
}

AI Agent Compatibility

This node is fully compatible with n8n's AI Agent nodes and can be used as a tool. The AI can:

  • Upload files provided by users or generated content
  • Download and retrieve files for processing
  • Manage storage by creating buckets and organizing files
  • Batch operations for handling multiple files efficiently

AI-Friendly Features

  • Clear operation descriptions that help AI understand capabilities
  • Comprehensive error handling with meaningful messages
  • Flexible input handling for various data sources
  • Structured responses for easy AI interpretation

API Reference

Supported Cloudflare R2 Features

  • Object Storage: Full CRUD operations
  • Bucket Management: Complete lifecycle management
  • CORS Policies: Cross-origin resource sharing
  • Batch Operations: Efficient bulk operations
  • Custom Metadata: Attach metadata to objects
  • Multipart Uploads: Large file support (coming soon)
  • Lifecycle Policies: Automated object management (coming soon)
  • Event Notifications: Webhook integrations (coming soon)

Response Formats

All operations return structured JSON responses:

{
  "success": true,
  "object": {
    "key": "path/to/file.txt",
    "size": 1024,
    "etag": "d41d8cd98f00b204e9800998ecf8427e", 
    "last_modified": "2023-12-01T10:30:00Z",
    "content_type": "text/plain"
  }
}

Development

Building from Source

# Clone repository
git clone https://github.com/jezweb/n8n-nodes-cloudflare-r2.git
cd n8n-nodes-cloudflare-r2

# Install dependencies
npm install

# Build the project
npm run build

# Link for local testing
npm link
cd ~/.n8n/custom
npm link n8n-nodes-cloudflare-r2-storage

Testing

# Lint code
npm run lint

# Format code 
npm run format

# Build and test
npm run build

Advanced Configuration

Custom Endpoints

For enterprise or specialized deployments, you can configure custom API endpoints:

{
  "accountId": "your-account-id",
  "apiToken": "your-api-token", 
  "apiEndpoint": "https://api.custom.cloudflare.com/client/v4"
}

Location Hints

Optimize performance by specifying geographic location hints when creating buckets:

  • ENAM: Eastern North America
  • WNAM: Western North America
  • EEUR: Europe
  • APAC: Asia-Pacific

Error Handling

The node provides comprehensive error handling:

  • Validation errors: Invalid bucket names, object keys
  • API errors: Authentication, permissions, rate limits
  • Network errors: Connection timeouts, DNS issues
  • Resource errors: Bucket not found, object not found

Troubleshooting

Common Issues

"Invalid bucket name"

  • Bucket names must be 3-63 characters
  • Only lowercase letters, numbers, hyphens, periods
  • Cannot be formatted as IP address

"Authentication failed"

  • Verify Account ID is correct
  • Ensure API token has R2:Edit permissions
  • Check token hasn't expired

"Object not found"

  • Verify bucket name and object key are correct
  • Ensure object exists in the specified bucket
  • Check for case sensitivity in object keys

Support

License

MIT License - see LICENSE file for details.

Changelog

See CHANGELOG.md for version history and updates.


Built with ❤️ by Jez (Jeremy Dawes) | Powered by Cloudflare R2