This comprehensive guide will walk you through the entire process of setting up CloudFlare R2 to work with the FluentCommunity Plugin. We’ll cover how to create and configure an R2 bucket, generate API tokens, and set up the plugin’s settings.
Follow these steps to set up Cloudflare R2 with your FluentCommunity.
Cloudflare Account ID #
First, log in to Your CloudFlare Account, then in the dashboard of your Cloudflare account you will find the Account ID.
Create a CloudFlare R2 Bucket (Bucket Name & Public URL) #
Navigate to R2 Object Storage from the left sidebar, find Overview under R2 Object Storage, and click on it. Now click on the Create Bucket button to create a bucket.
Enter a name for your bucket that is easy to identify and unique across your projects. Leave the Location of the bucket as Default unless you have specific storage.
Double-check your settings and click the Create Bucket button.
Cloudflare Bucket Public URL #
Now here you will be able to see the Bucket Details. Scroll down for the R2.dev Subdomain section. Here you need to Allow Access to this R2.dev subdomain.
Click the Allow Access button, and a pop-up will appear. Type “allow” in the field to grant access to the Public R2.dev Bucket URL.
Now from here, you will get the Cloudflare Bucket Public URL.
Cloudflare Access Key & Secret Key #
To create a Cloudflare Access Key go to your Cloudflare account dashboard again and click on the Manage R2 API Token.
Now you will be redirected to the R2 page here click on the Create API Token button.
The API creation page will appear, where you’ll need to configure the settings for your API. Start by giving your API a Name. In the Permissions section, select Object Read and Write permission.
Next, choose the Bucket where you want to store your files from the dropdown menu. Adjust any other settings as needed, and then click the Create API Token button.
Here, you will find the Access Key and Secret Key. Make sure to copy them immediately, as you won’t be able to revisit this page later.
Configure FluentCommunity #
Now access FluentCommunity and go to Settings > Features & Addons. Here you will see the Media Module section and click on the Configure button.
Next, select Cloudflare R2 and enter the credentials you collected from your Cloudflare account in the earlier steps of this guide.
Cloudflare Account ID: Input your CloudFlare Account ID.
Cloudflare Access Key: Paste the Access Key you got earlier from your CloudFlare API token.
Cloudflare Secret Key: Enter the Secret Key from your CloudFlare API token.
Cloudflare Bucket Name: Enter the name of the R2 bucket you created.
Cloudflare Bucket Public URL: Provide the Public R2.dev Bucket URL.
Bucket Sub-Folder (Optional): If you’d like to organize files within a specific subfolder in your bucket, specify the subfolder name here.
Once all fields are filled in correctly, click the Save Settings button to store your configuration.
Additional Configuration (Optional) #
For more advanced setups, you can define your CloudFlare R2 settings in your wp-config.php file. This method provides an extra layer of security and is useful for managing configurations across different environments.
Add These Lines to wp-config.php: #
php
Copy code
// CloudFlare R2 Configuration
define('FLUENT_COMMUNITY_CLOUD_STORAGE', 'cloudflare_r2');
define('FLUENT_COMMUNITY_CLOUD_STORAGE_ACCOUNT_ID', 'YOUR_ACCOUNT_ID'); // Example: 1718cb5a51e65c8f19e8sahdakh763
define('FLUENT_COMMUNITY_CLOUD_STORAGE_ACCESS_KEY', 'YOUR_ACCESS_KEY');
define('FLUENT_COMMUNITY_CLOUD_STORAGE_SECRET_KEY', 'YOUR_SECRET_KEY');
define('FLUENT_COMMUNITY_CLOUD_STORAGE_BUCKET', 'YOUR_BUCKET_NAME');
define('FLUENT_COMMUNITY_CLOUD_STORAGE_PUBLIC_URL', 'https://pub-SOME_RANDOM_STRINGS.r2.dev'); // Custom domain if configured
define('FLUENT_COMMUNITY_CLOUD_STORAGE_SUB_FOLDER', 'your-subfolder-name'); // Optional
Note: Defining these values in wp-config.php will override any settings configured in the FluentCommunity plugin’s admin panel.
Troubleshooting Common Issues #
- API Token Permissions: Ensure your API token has the correct permissions for R2 access.
- Incorrect Bucket or URL: Double-check that your bucket name and public URL are accurate and correctly configured.
- Custom Domain Setup: If using a custom domain, confirm it is properly configured in CloudFlare to avoid connectivity issues.
For any additional support, feel free to reach out to our support team. We’re here to assist you!