@ridoy_sarker/medusa-cloudinary
v2.0.0
Published
medusa cloudinary plugin v2.
Downloads
128
Maintainers
Readme
Features
- 🖼️ Upload and manage files using Cloudinary
- 🔒 Secure file uploads with API authentication
- 📁 Organize files in custom folders
- ✅ Compatible with Medusa v2
Compatibility
This plugin is compatible with versions >= 2.4.0 of @medusajs/medusa.
Installation
npm install @ridoy_sarker/medusa-cloudinaryor
yarn add @ridoy_sarker/medusa-cloudinaryConfiguration
1. Get Cloudinary Credentials
Sign up for a Cloudinary account and get your:
- Cloud Name
- API Key
- API Secret
2. Add Environment Variables
Add the following to your .env file:
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret3. Configure Medusa
Add the plugin to your medusa-config.ts or medusa-config.js:
module.exports = defineConfig({
projectConfig: {
// ... other config
},
modules: [
{
resolve: "@medusajs/medusa/file",
options: {
providers: [
{
resolve: "@ridoy_sarker/medusa-cloudinary/providers/cloudinary",
id: "cloudinary",
options: {
apiKey: process.env.CLOUDINARY_API_KEY,
apiSecret: process.env.CLOUDINARY_API_SECRET,
cloudName: process.env.CLOUDINARY_CLOUD_NAME,
folderName: "store", // Optional: Folder name in Cloudinary
secure: true, // Optional: Use HTTPS (default: true)
},
},
],
},
},
],
});Usage
Once configured, the Cloudinary provider will be used automatically for file uploads in your Medusa application. You can upload files through:
- Admin dashboard (product images, etc.)
- API endpoints that handle file uploads
- Custom workflows that use the file module
Example: Upload File Programmatically
import { MedusaRequest, MedusaResponse } from "@medusajs/framework";
export async function POST(req: MedusaRequest, res: MedusaResponse) {
const fileModuleService = req.scope.resolve("file");
const uploadedFile = await fileModuleService.uploadFile({
filename: "product-image.jpg",
mimeType: "image/jpeg",
content: fileBuffer, // Buffer or Stream
});
res.json({ file: uploadedFile });
}Options
| Option | Type | Required | Default | Description |
|--------|------|----------|---------|-------------|
| apiKey | string | Yes | - | Your Cloudinary API key |
| apiSecret | string | Yes | - | Your Cloudinary API secret |
| cloudName | string | Yes | - | Your Cloudinary cloud name |
| folderName | string | No | "medusa" | Folder name in Cloudinary for organizing files |
| secure | boolean | No | true | Use HTTPS for file URLs |
Compatibility Matrix
This plugin is compatible with versions >= 2.4.0 of @medusajs/medusa.
Getting Started
Visit the Quickstart Guide to set up a server.
Visit the Plugins documentation to learn more about plugins and how to create them.
Visit the Docs to learn more about our system requirements.
What is Medusa
Medusa is a set of commerce modules and tools that allow you to build rich, reliable, and performant commerce applications without reinventing core commerce logic. The modules can be customized and used to build advanced ecommerce stores, marketplaces, or any product that needs foundational commerce primitives. All modules are open-source and freely available on npm.
Learn more about Medusa’s architecture and commerce modules in the Docs.
Community & Contributions
The community and core team are available in GitHub Discussions, where you can ask for support, discuss roadmap, and share ideas.
Join our Discord server to meet other community members.
