Cloudflare R2 Storage Datasource Plugin
Author: aopstudio
Version: 0.0.1
Type: datasource
Introduction
This plugin integrates with Cloudflare R2 Storage, enabling automated access to your R2 buckets and objects. It supports browsing files and folders within R2 buckets and downloading files directly for use in platforms like Dify.
Features
- Browse R2 Buckets: List all available R2 buckets in your Cloudflare account
- Browse Bucket Contents: Navigate through folders and files within R2 buckets
- Download Files: Retrieve files from R2 buckets for processing
- Folder Navigation: Support for hierarchical folder structure browsing
- Pagination Support: Efficiently handle large numbers of files with pagination
Setup
Prerequisites
Before using this plugin, you need:
- An Cloudflare account with active R2 service
- R2 buckets with the files you want to access
- Cloudflare credentials with appropriate permissions
Configuration Steps
-
Create API token for R2 (if not already exists):
- Sign in to the Cloudflare Dash
- Navigate to R2 object storage
- Click "Manage API tokens" → "Create User API token"
-
Set Permissions:
- Provide a token name
- Attach policies that grant R2 access:
- (for read-only access to all buckets)
- Click "Create User API token"
-
Save Access Keys:
- Save the Access Key ID and Secret Access Key securely
-
Configure the Plugin in Dify:
- Access Key ID: Enter the Access Key ID from your Cloudflare API token
- Secret Access Key: Enter the Secret Access Key from your Cloudflare API token
- Region Name: Enter your Cloudflare region (e.g., , , , , , )
- Account ID: Enter your Cloudflare Account ID (you can get it from your address bar)
- Click "Save" to store the credentials
Usage
Browsing Files
The plugin provides an online drive interface for browsing R2 content:
- List Buckets: When no bucket is specified, the plugin lists all available R2 buckets
- Browse Bucket Contents: Select a bucket to view its files and folders
- Navigate Folders: Click on folders to browse their contents
- Pagination: Use pagination controls for buckets with many files
Downloading Files
To download a file:
- Browse to the desired file
- Select the file for download
- The plugin retrieves the file content and metadata
Supported Operations
| Operation | Description |
|---|
| List Buckets | View all R2 buckets in your Cloudflare account |
| Browse Files | Navigate through files and folders in a bucket |
| Download File | Retrieve file content from R2 |
| Pagination | Handle large file lists with continuation tokens |
Security Considerations
- Credentials: Store your Cloudflare credentials securely and never share them
- Permissions: Use the principle of least privilege - grant only necessary R2 permissions
- Region: Ensure you're using the correct Cloudflare region for your buckets
- Encryption: Consider using R2 server-side encryption for sensitive data
Troubleshooting
Common Issues
-
"Credentials not found" error:
- Verify that Access Key ID and Secret Access Key are correctly configured
-
"Access Denied" error:
- Verify the bucket policy allows access from your API token
-
"Bucket not found" error:
- Check that the bucket name is correct
- Ensure the bucket exists in the specified region
-
Region connectivity issues:
- Verify the region name is correct (e.g., )
- Ensure the bucket exists in the specified region
Cloudflare Regions
Common Cloudflare R2 regions include:
- (Western North America)
- (Eastern North America)
- (Western Europe)
- (Eastern Europe)
- (Asia-Pacific)
Privacy
Please refer to the Privacy Policy for information on how your data is handled when using this plugin.
Support
For issues or questions:
Last updated: September 2025