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
Maintainers
Readme
n8n-nodes-cloudflare-r2
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
- Operations
- Credentials
- Usage Examples
- AI Agent Compatibility
- API Reference
- Development
- Support
Installation
Via n8n Community Nodes (Recommended)
- Go to Settings → Community Nodes in your n8n instance
- Enter
n8n-nodes-cloudflare-r2-storagein the Package field - Click Install
- 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 n8nOperations
🪣 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)
- Go to Cloudflare Dashboard
- Click "Create Token" → "Custom token"
- Configure permissions:
- Account:
Cloudflare R2:Edit - Zone Resources:
Include - All zones(if using custom domains)
- Account:
- Copy the generated token
2. R2 Access Keys (for object operations)
- Go to your Cloudflare R2 Dashboard
- Select R2 → Manage R2 API Tokens
- Click "Create API Token"
- 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
- Click "Create API Token"
- 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-storageTesting
# Lint code
npm run lint
# Format code
npm run format
# Build and test
npm run buildAdvanced 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
- 🐛 Bug Reports: GitHub Issues
- 💡 Feature Requests: GitHub Discussions
- 📖 Documentation: Cloudflare R2 Docs
- 💬 Community: n8n Community Forum
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
