Управляйте файловым хранилищем через MinIO
🗄️ Seamless MinIO file storage integration for MedusaJS - Self-hosted, S3-compatible object storage
1graph TD2 A[MedusaJS] -->|File Upload| B[MinIO Storage]3 B -->|Public Files| C[CDN]4 B -->|Private Files| D[Secure Bucket]5 6 subgraph File Management7 Upload[File Upload]8 Download[Presigned URLs]9 Metadata[Custom Metadata]10 endInstall the package using npm:
npm install @vymalo/medusa-minioOr using yarn:
yarn add @vymalo/medusa-minio1modules: [2 {3 resolve: '@medusajs/medusa/file',4 options: {5 providers: [6 {7 resolve: '@vymalo/medusa-minio',8 id: 'minio',9 options: {10 endpoint: process.env.MINIO_ENDPOINT,11 cdn_url: process.env.MINIO_CDN_URL,12 bucket: process.env.MINIO_BUCKET,13 private_bucket: process.env.MINIO_PRIVATE_BUCKET 14 || process.env.MINIO_BUCKET,15 access_key_id: process.env.MINIO_ACCESS_KEY,16 secret_access_key: process.env.MINIO_SECRET_KEY,17 },18 },19 ],20 },21 },22]1interface MinioOptions {2 // Required Basic Configuration3 endpoint: string; // MinIO server endpoint4 cdn_url: string; // CDN URL for public files5 bucket: string; // Default public bucket6 access_key_id: string; // MinIO access key7 secret_access_key: string; // MinIO secret key8
9 // Optional Advanced Settings10 private_bucket?: string; // Separate private bucket11 download_url_duration?: number; // Presigned download URL expiry12 upload_url_duration?: number; // Presigned upload URL expiry13
14 // Customization Hooks15 uploadMetadata?: (file: ProviderUploadFileDTO | ProviderGetPresignedUploadUrlDTO) => ItemBucketMetadata; // Custom metadata generator16 buildKey?: (file: ProviderUploadFileDTO | ProviderGetPresignedUploadUrlDTO) => string; // Custom file key generator17}1buildKey: (file) => {2 // Generate custom file path/key3 return `uploads/${new Date().toISOString()}/${file.originalName}`;4}1uploadMetadata: (file) => ({2 'x-amz-meta-my-key': 'custom-value',3 'content-type': file.mimetype4})Required Environment Variables:
Optional Environment Variables:
Contributions are welcome! Please submit pull requests or open issues.