medusa-plugin-cloudflare-images
v0.1.0
Published
Cloudflare Images File Module Provider for Medusa v2.
Maintainers
Readme
Medusa Cloudflare Images File Provider
Cloudflare Images File Module Provider for Medusa v2.
This provider stores Medusa uploads in Cloudflare Images and returns delivery URLs that can be used by product media and custom file workflows.
Installation
pnpm add medusa-plugin-cloudflare-imagesUse the equivalent install command for npm, yarn, or bun if needed.
Configuration
Register the provider in medusa-config.ts:
import { defineConfig, loadEnv } from "@medusajs/framework/utils"
loadEnv(process.env.NODE_ENV || "development", process.cwd())
module.exports = defineConfig({
modules: [
{
resolve: "@medusajs/medusa/file",
options: {
providers: [
{
resolve: "medusa-plugin-cloudflare-images/providers/cloudflare-images",
id: "cloudflare-images",
options: {
account_id: process.env.CLOUDFLARE_IMAGES_ACCOUNT_ID,
api_token: process.env.CLOUDFLARE_IMAGES_API_TOKEN,
account_hash: process.env.CLOUDFLARE_IMAGES_ACCOUNT_HASH,
delivery_url: process.env.CLOUDFLARE_IMAGES_DELIVERY_URL,
variant: process.env.CLOUDFLARE_IMAGES_VARIANT || "public",
prefix: process.env.CLOUDFLARE_IMAGES_PREFIX,
},
},
],
},
},
],
})The Medusa File Module accepts one provider. Register this provider instead of the local or S3 file provider.
Options
Required:
CLOUDFLARE_IMAGES_ACCOUNT_ID=
CLOUDFLARE_IMAGES_API_TOKEN=Delivery configuration, at least one is required:
CLOUDFLARE_IMAGES_ACCOUNT_HASH=
CLOUDFLARE_IMAGES_DELIVERY_URL=Optional:
CLOUDFLARE_IMAGES_VARIANT=public
CLOUDFLARE_IMAGES_PREFIX=productsSet CLOUDFLARE_IMAGES_DELIVERY_URL when serving through a custom delivery base
URL. Otherwise the provider builds URLs as:
https://imagedelivery.net/<account_hash>/<image_id>/<variant>prefix is optional for regular uploads and direct uploads. It is required for
stream uploads because Medusa expects the provider to return the final file key
and URL before the upload stream has completed.
