@vymalo/medusa-minio
v1.0.10
Published
๐๏ธ Seamless MinIO file storage integration for MedusaJS - Self-hosted, S3-compatible object storage
Maintainers
Readme
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 TD
A[MedusaJS] -->|File Upload| B[MinIO Storage]
B -->|Public Files| C[CDN]
B -->|Private Files| D[Secure Bucket]
subgraph File Management
Upload[File Upload]
Download[Presigned URLs]
Metadata[Custom Metadata]
endKey Capabilities
- Self-hosted object storage
- S3-compatible API
- Secure file management
- Flexible deployment options
๐ฆ Installation
Install the package using npm:
npm install @vymalo/medusa-minioOr 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 Configuration
endpoint: string; // MinIO server endpoint
cdn_url: string; // CDN URL for public files
bucket: string; // Default public bucket
access_key_id: string; // MinIO access key
secret_access_key: string; // MinIO secret key
// Optional Advanced Settings
private_bucket?: string; // Separate private bucket
download_url_duration?: number; // Presigned download URL expiry
upload_url_duration?: number; // Presigned upload URL expiry
// Customization Hooks
uploadMetadata?: (file: ProviderUploadFileDTO | ProviderGetPresignedUploadUrlDTO) => ItemBucketMetadata; // Custom metadata generator
buildKey?: (file: ProviderUploadFileDTO | ProviderGetPresignedUploadUrlDTO) => string; // Custom file key generator
}Customization Examples
Custom File Key Generation
buildKey: (file) => {
// Generate custom file path/key
return `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_ENDPOINT: MinIO server URLMINIO_CDN_URL: CDN endpoint for public filesMINIO_BUCKET: Default public bucket nameMINIO_ACCESS_KEY: MinIO access keyMINIO_SECRET_KEY: MinIO secret key
Optional Environment Variables:
MINIO_PRIVATE_BUCKET: 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.
