WooCommerce R2 Downloads
Store your WooCommerce downloadable products on Cloudflare R2 for faster downloads, better server performance, and significantly lower costs.
Used on high traffic production sites from day 1, this plugin is battle tested and ready to go!
This plugin is fully compatible with existing on-server downloads in WooCommerce, so you can use R2 for just the files you need or everything.
Migrate from AWS S3
Backwards compatible with the WooCommerce S3 Storage plugin so you can migrate to this easily.
R2 has much much cheaper outbound data (egress) than AWS S3 or Cloudfront so it is a great choice for digital downloads.
Some websites can reduce their spending by thousands of dollars a year - check out the R2 calculator here.
How is Cloudflare R2 able to offer this service at a price that undercuts AWS S3 by so much?
Bandwidth for providers isn't billed by the gigabyte like you are on AWS so at certain scales the costs involved are completely different shapes. Read up on that here.
Usage instructions
First you should upload your products to R2. I like using Cyberduck to make life easy.
In the File URL field in WooCommerce, use the following shortcode:
[cloudflare_r2 bucket="my-bucket" object="path/filename.ext"]
Because this plugin is backwards compatible with WooCommerce S3 Storage you can also use their shortcode:
[amazon_s3 bucket="my-bucket" object="path/filename.ext"]
If you specify the default bucket in your settings you can skip the bucket field.
Setup Instructions
You now have two ways to set up the plugin:
Using the Settings Page
- Go to WooCommerce → Settings → Products → R2 Downloads
- Enter your Cloudflare R2 credentials and settings
- Test your connection directly from the settings page
- Save your settings and you're ready to go
Using wp-config.php constants
You can also use wp-config.php if you prefer. Set up your configuration like this:
define('CF_ACCESS_KEY', '');
define('CF_ACCESS_SECRET', '');
define('CF_ACCOUNT_ID', '');
define('CF_DEFAULT_BUCKET', '');
You can use either method or mix both - constants in wp-config.php will take precedence and will appear as read-only in the settings page.
WooCommerce settings
It is best if WooCommerce is setup to use the Redirect or X-Accel-Redirect/X-Sendfile download methods.
You can do this under WooCommerce -> Settings -> Products -> Downloadable Products and ensure File download method is set to Redirect only or X-Accel-Redirect/X-Sendfile.
Your products are still fully secure and links are only valid for 1 hour by default.
Upload files directly to R2
Once configured you should upload your files to R2 or migrate them from S3 to R2.
You can use a third-party tool like Cyberduck or upload them directly from the Cloudflare website.
URL Validity time
If you want to change the time period that the URL is download valid for you can use settings page or CF_URL_PERIOD
constant to specify how many minutes links should be valid for:
define('CF_URL_PERIOD', 15); // 15 minutes
Bucket mapping
In case your buckets are named differently between AWS and R2 you can use CF_BUCKET_MAP
to automatically convert for new requests.
To map the following:
- your_aws_bucket1 -> your_r2_bucket1
- a_diff_aws -> new_r2_bucket
Either add this to your Bucket Map setting:
your_aws_bucket1:your_r2_bucket1,a_diff_aws:new_r2_bucket
or add the following constant to wp-config.php
:
define('CF_BUCKET_MAP', 'your_aws_bucket1:your_r2_bucket1,a_diff_aws:new_r2_bucket');
Support
If you need any help at all I answer emails quickly and at no cost to help you resolve any issues with the plugin. Please send through as much information as you can in your initial email. My address is ryan@viennaandbailey.co.nz
More complex help is available and will be billed at an hourly rate.
Updates
This plugin is actively maintained on live high-traffic stores and is designed to not need regular updates. You will be emailed for any important updates released.
v1.3.0 - 2025 / 04 / 09
- Improved Analytics Report display of URLs
v1.2.2 - 2025 / 04 / 08
- Added the settings page
v1.1.0 - 2025 / 04 / 07
- Automatically add URLs to the Approved Downloads list
- Prevent checking for AWS config file
v1.0.0 - 2024 / 03 / 29
- Initial release
Future updates
- If you would like a Backblaze B2 variant please send me an email!
woocommerce-r2-downloads-1.3.0.zip