Built by

viceverse-cz

Category

Storage

Version

1.1.1

Last updated

Apr 8, 2023, 10:19:55 AMa year ago

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

  1. Installation
  2. Configuration
  3. Obtaining Credentials
  4. Usage
  5. Credits

Installation

To get started with the Medusa Cloudflare R2 plugin, you will first need to install the package using npm:
npm 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 clipboardmedusa-config.js file:
{
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 clipboardoptions 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:
  1. Account ID
  2. Bucket Name
  3. Public URL
  4. Access Key ID
  5. Secret Access Key
You can obtain these credentials by logging into your Cloudflare account and navigating to the R2 Storage section. If you do not already have a Cloudflare account, you will need to sign up for one.
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.

Build your own plugins

Develop your own plugins with our API to speed up your processes.

Make your plugin available via npm for it to be shared in our Plugin Library with the broader Medusa community.