Besides Amazon S3 and Cloudflare R2, Amazon S3 Storage can connect experimentally to Backblaze B2, Wasabi and DigitalOcean Spaces. These providers have no fields in the settings: you set the provider, endpoint and keys with a short PHP snippet, and support for them is best effort. This needs Amazon S3 Storage for WooCommerce 3.3.0 or newer.
To follow this page, you should be comfortable adding code snippets to your WooCommerce store. Using Cloudflare R2? It’s built in, so follow Connect Cloudflare R2 instead and don’t use a snippet.
When you’d use this
- Your files already live with Backblaze B2, Wasabi or DigitalOcean Spaces.
- You want to try one of these providers before committing to it, and you’re comfortable checking the results yourself.
How to use it
1. Gather your provider’s details
You need a bucket, an access key pair that can list buckets and read and write files, the provider’s region, and its S3 endpoint:
| Provider | Keys | Endpoint |
|---|---|---|
| Backblaze B2 | Application key ID and application key | https://s3.<region>.backblazeb2.com (the region is part of your bucket’s S3 endpoint, such as us-west-004) |
| Wasabi | Access key and secret key | https://s3.<region>.wasabisys.com |
| DigitalOcean Spaces | Spaces access key and secret | https://<datacenter>.digitaloceanspaces.com |
- Backblaze B2: Region is the one in your bucket’s S3 endpoint, for example
us-west-004ins3.us-west-004.backblazeb2.com. - Wasabi: Region is your bucket’s region, such as
us-west-1oreu-central-1. Choose the endpoint that matches it in Wasabi’s service URL list. - DigitalOcean Spaces: Keep Region as
us-east-1here and in the shortcode’sregionattribute. The datacenter comes from the endpoint, for examplehttps://nyc3.digitaloceanspaces.com.
Your provider’s documentation lists its regions and endpoints. Create your buckets with the provider: the plugin can’t create them for you.
2. Choose the experimental provider setting
Go to WooCommerce » S3 storage, set Cloud service provider to User defined (experimental), and click Save changes. The credentials and endpoint fields disappear, because the snippet supplies them. Until you add the snippet, the page shows: "You have selected to use an experimental cloud service provider. This is an advanced setup that requires utilizing specific WordPress filter hooks."
3. Add the snippet
Add this snippet with your own values in place of the text in angle brackets. The first filter names the provider: backblaze, wasabi or digitalocean. The second passes the region, endpoint and keys to the storage client. This example is for Backblaze B2:
add_filter( 'woocommerce_amazon_s3_client_cloud_service', fn() => 'backblaze' );
add_filter( 'woocommerce_amazon_s3_client_args', function( $args ) {
return array_merge( $args, [
'region' => '<your region>',
'endpoint' => 'https://s3.<your region>.backblazeb2.com',
'credentials' => [
'key' => '<your application key ID>',
'secret' => '<your application key>',
],
] );
} );
Don’t use the provider name cloudflare here: Cloudflare R2 is chosen in the settings instead. Change the endpoint line for any provider other than Backblaze B2.
The same snippet is kept up to date in our public snippets library.
4. Choose a bucket and test
Reload WooCommerce » S3 storage. With an experimental provider, the plugin doesn’t test the connection, so the remaining sections show whether or not the snippet works. Choose your bucket under S3 bucket (an empty list means the keys or endpoint are wrong), tick Enable if you want automatic offloading, and save.
Then save a downloadable product and check its S3 status. Automatic offloading works only when your bucket’s region code is in the plugin’s Default region list (see the list). If the file shows Failed, upload your files with the provider’s own tools and link them with the S3 shortcode: edit a product and, in the downloadable file’s File URL field, enter [amazon_s3 object=path/file.pdf bucket=your-bucket-name region=your-region]. The Add S3 file shortcode button under the downloadable files table builds it for you. Use the same region as in your snippet. You can leave out the bucket once you choose a Default bucket under Shortcode offloading.
Common issues
A file shows Failed
With Debug mode on, the log shows "Failed to get region for bucket". The plugin doesn’t recognize your provider’s region code, so it can’t offload to that bucket. Link your files with the S3 shortcode instead, with bucket and region in each.
The bucket dropdown is empty
The plugin couldn’t list your buckets. Check the keys, region and endpoint in the snippet, and that the key is allowed to list buckets. Turn on Debug mode and look for "Failed to list buckets" under WooCommerce » Status » Logs.
Downloads fail with SignatureDoesNotMatch or 403 Forbidden
The region or endpoint doesn’t match the bucket, or the key pair is wrong. Copy them again from your provider and update the snippet.
Some providers reject requests because of the X-Amz-User-Agent header
Since version 3.5.1 you can remove the header by adding this line to the same snippet:
add_filter( 'woocommerce_amazon_s3_client_remove_amz_user_agent', '__return_true' );
Try it when you get SignatureDoesNotMatch and the region, endpoint and keys are right.
"A connection to Amazon S3 could not be initialized: the access key ID is not valid."
Or "…the secret access key does not match the access key ID." (3.5.4 and newer.) These come from the connection check that runs for Amazon S3 and Cloudflare R2, so Cloud service provider probably isn’t set to User defined (experimental). Set it, save, and keep your provider’s keys in the snippet, not in the settings page.
"Could not produce a valid S3 link from shortcode"
With Debug mode on, this appears in the plugin’s log when the plugin couldn’t sign the download link, usually because it can’t build a connection from your snippet. Check the snippet’s endpoint and your access keys. A shortcode that’s missing its bucket, region or object logs a different message: "The required S3 shortcode arguments are missing. Cannot initialize a connection to S3."
I need more detail in the logs
Tick Debug mode in the settings. For the raw requests to your provider as well, add this line for a short time, then remove it, because it logs a lot of data:
add_filter( 'woocommerce_amazon_s3_client_debug_mode', '__return_true' );
Something still doesn’t work
Experimental providers may not support every feature. Contact our support team with your site URL, the provider and what you see; we’re glad to help where we can and to hear what would make your provider work better.
