Medusa Cloudflare R2 Plugin Documentation
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.
Table of Contents
Installation
To get started with the Medusa Cloudflare R2 plugin, you will first need to install the package using npm:1npm i @vicecommerce/medusa-file-r2
Configuration
After installing the plugin, you need to configure it in your Medusa project. You can do this by adding the following object to the Copy to clipboard
medusa-config.js
file:12345678910{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 Copy to clipboard
options
object with the appropriate
environment variables containing your Cloudflare R2 credentials.Obtaining Credentials
To use the Medusa Cloudflare R2 plugin, you will need the following 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.
Usage
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.
For example, when using Medusa to manage product images, the images will be
uploaded to your specified Cloudflare R2 bucket.
Credits
The Medusa Cloudflare R2 plugin is based on the original work by contrebande-labs.