cloudflare_storage
Manage Cloudflare R2 object storage buckets from Drupal as configuration: define a bucket, choose public or private access, and let other Cloudflare modules store and serve files from it.
Cloudflare R2 is S3-compatible object storage with no egress fees. This module models each R2 bucket as a first-class Drupal asset (a configuration entity), provisions and inspects it through the Cloudflare API, and keeps its public or private state in sync. On its own it does not serve files; it is the shared bucket layer that file systems and caches build on. For an R2-backed public and private file system, install Cloudflare R2 File System.
Features
- An R2 bucket configuration entity (bucket name, credential set, and public or private access), managed from an admin screen.
- Public or private access is authoritative in Drupal and reconciled to the R2 API, so a private bucket is genuinely unreachable publicly rather than just served differently.
- Public URLs resolved from the Cloudflare API: a custom domain when one is set, otherwise the managed r2.dev domain.
- Bucket provisioning and inspection through the Cloudflare SDK's primitive and reconciler framework, so a feature module can declare the bucket it needs and have it created.
- The R2 S3 keypair (access key ID and secret) is resolved from settings.php, kept out of configuration and the database.
Use this module when another Cloudflare module needs an R2 bucket, or when you want to define and provision R2 buckets from Drupal rather than from the Cloudflare dashboard.
Post-Installation
This module has no user-facing output of its own; it provides bucket assets that other modules consume. After enabling it:
- Make sure you have a credential set from the Cloudflare SDK, with its account ID and API token in settings.php.
- Add that credential set's R2 S3 keypair (access key ID and secret) to settings.php.
- Add a bucket at Configuration > Web services > Cloudflare R2 buckets: give it a label, the R2 bucket name, the credential set, and whether it is public or private.
Other Cloudflare modules then reference the bucket by its machine name.
Additional Requirements
Requires the Cloudflare SDK and Cloudflare API modules, which Composer installs automatically, plus a Cloudflare account with R2 enabled and an R2 S3 access keypair. Install with Composer:
composer require drupal/cloudflare_storageWhile the suite is in alpha, require it as drupal/cloudflare_storage:^1.0@alpha (or set your project's minimum-stability to alpha) so the pre-stable releases resolve.
Recommended modules/libraries
Cloudflare R2 File System turns a bucket into a Drupal file system for public and private files, including on-demand image styles.
Similar projects
S3 File System stores files in Amazon S3 or S3-compatible services. This module is R2-specific: it manages the bucket as Drupal configuration, provisions it through the Cloudflare API, and controls public or private access at Cloudflare rather than only in how files are served. It pairs with Cloudflare R2 File System for the file system itself.
Supporting this Module
Issue reports, patches and feedback are welcome in the project's issue queue.
Community Documentation
For creating a Cloudflare API token, see Cloudflare's documentation at developers.cloudflare.com/fundamentals/api/get-started/create-token. For R2, see developers.cloudflare.com/r2.