The Medusa Cloudflare R2 plugin is a simple and easy-to-use plugin that allows you to use Cloudflare R2 as the storage provider for Medusa. Medusa Cloudflare R2 Plugin Documentation
Table of Contents
To get started with the Medusa Cloudflare R2 plugin, you will first need to install the package using npm: Installation
npm i @vicecommerce/medusa-file-r2
After installing the plugin, you need to configure it in your Medusa project. You can do this by adding the following object to the `medusa-config.js` file: Configuration
{
resolve: "@vicecommerce/medusa-file-r2",
options: {
account_id: process.env.R2_ACCOUNT_ID,
bucket: process.env.R2_BUCKET_NAME,
public_url: process.env.R2_PUBLIC_URL,
access_key_id: process.env.R2_ACCESS_KEY,
secret_access_key: process.env.R2_SECRET_KEY,
},
}
Make sure to replace the values in the options
object with the appropriate
environment variables containing your Cloudflare R2 credentials.
To use the Medusa Cloudflare R2 plugin, you will need the following credentials: Obtaining Credentials
- Account ID
- Bucket Name
- Public URL
- Access Key ID
- Secret Access Key
For detailed instructions on obtaining your Cloudflare R2 credentials, please refer to the official Cloudflare R2 documentation.
Once you have installed and configured the plugin, you can use it to store files with Medusa. The plugin will automatically handle uploading and deleting files on your Cloudflare R2 storage. Usage
For example, when using Medusa to manage product images, the images will be uploaded to your specified Cloudflare R2 bucket.