M
Minio
🗄️ Seamless MinIO file storage integration for MedusaJS - Self-hosted, S3-compatible object storage
MedusaJS Minio File Storage Provider
🗄️ Seamless MinIO file storage integration for MedusaJS - Self-hosted, S3-compatible object storage
🌟 Features
- Direct integration with MinIO object storage
- Support for public and private buckets
- Configurable CDN and upload options
- Flexible file key and metadata generation
- Environment variable-driven configuration
🏗️ Architecture Overview
graph TDA[MedusaJS] -->|File Upload| B[MinIO Storage]B -->|Public Files| C[CDN]B -->|Private Files| D[Secure Bucket]subgraph File ManagementUpload[File Upload]Download[Presigned URLs]Metadata[Custom Metadata]end
Key Capabilities
- Self-hosted object storage
- S3-compatible API
- Secure file management
- Flexible deployment options
📦 Installation
Install the package using npm:
npm install @vymalo/medusa-minio
Or using yarn:
yarn add @vymalo/medusa-minio
🚀 Configuration
Plugin Setup
modules: [{resolve: '@medusajs/medusa/file',options: {providers: [{resolve: '@vymalo/medusa-minio',id: 'minio',options: {endpoint: process.env.MINIO_ENDPOINT,cdn_url: process.env.MINIO_CDN_URL,bucket: process.env.MINIO_BUCKET,private_bucket: process.env.MINIO_PRIVATE_BUCKET|| process.env.MINIO_BUCKET,access_key_id: process.env.MINIO_ACCESS_KEY,secret_access_key: process.env.MINIO_SECRET_KEY,},},],},},]
🔧 Advanced Configuration Options
interface MinioOptions {// Required Basic Configurationendpoint: string; // MinIO server endpointcdn_url: string; // CDN URL for public filesbucket: string; // Default public bucketaccess_key_id: string; // MinIO access keysecret_access_key: string; // MinIO secret key// Optional Advanced Settingsprivate_bucket?: string; // Separate private bucketdownload_url_duration?: number; // Presigned download URL expiryupload_url_duration?: number; // Presigned upload URL expiry// Customization HooksuploadMetadata?: (file: ProviderUploadFileDTO | ProviderGetPresignedUploadUrlDTO) => ItemBucketMetadata; // Custom metadata generatorbuildKey?: (file: ProviderUploadFileDTO | ProviderGetPresignedUploadUrlDTO) => string; // Custom file key generator}
Customization Examples
Custom File Key Generation
buildKey: (file) => {// Generate custom file path/keyreturn `uploads/${new Date().toISOString()}/${file.originalName}`;}
Custom Metadata
uploadMetadata: (file) => ({'x-amz-meta-my-key': 'custom-value','content-type': file.mimetype})
🌐 Environment Variables
Required Environment Variables:
- : MinIO server URL
- : CDN endpoint for public files
- : Default public bucket name
- : MinIO access key
- : MinIO secret key
Optional Environment Variables:
- : Separate private bucket name
🛡️ Security Considerations
- Use strong, unique access keys
- Implement bucket-level access controls
- Rotate credentials regularly
- Use HTTPS for all communications
🤝 Contributing
Contributions are welcome! Please submit pull requests or open issues.