Cloudflare R2 requires PHP 8.0.2 or greater and Craft CMS 4.0.0 or 5.0.0 or greater.
1. Open your terminal and go to your Craft project:
2. Then tell Composer to load the plugin:
composer require jrrdnx/craft-cloudflare-r2
3. In the Control Panel, go to Settings -> Plugins and click the "Install" button for Cloudflare R2.
Visit the Cloudflare R2 page in the Plugin Store in your control panel and click the Install button.
- Navigate to Settings -> Filesystems and click the "New Filesystem" button.
- Select "Cloudflare R2" from the "Filesystem Type" dropdown.
- Enter your Account ID, Access Key ID, and Secret Access Key (it's recommended to store these in your `.env` file and reference the environment variables here).
- Hit Refresh to load the bucket list, or choose the Manual option and enter the bucket name (again, you can store this in your `.env` file and reference the environment variable).
- Optionally add a Subfolder, determine whether or not to add the Subfolder to the Base URL, and set the Cache Control duration.
Configuring a Cloudflare R2 Bucket and Worker for Public Access
I recently published a plugin to integrate Cloudflare R2 with Craft CMS. After having a chance to utilize this on a few more projects after its release, I wanted to put together a guide to streamline this process for future use cases. Hopefully this will help out any others out there looking to setup R2 on their Cloudflare accounts, as most of this won't be specific to Craft CMS.Learn More