esempio .env #MINIO MINIO_ENDPOINT=storage.gixflow.cloud MINIO_PORT=9100 MINIO_USE_SSL=true MINIO_ACCESS_KEY=gixflowadmin MINIO_SECRET_KEY=HAujhuhgdsajhdsabnUHVBhjMInjudsuhgdshy7567gdfs7ghu MINIO_REGION=us-east-1 MINIO_BUCKET_NAME=evoluzioneazienda-admin esempio config minioClient.js: const Minio = require("minio"); require("dotenv").config(); // Validazione obbligatoria della configurazione bucket if (!process.env.MINIO_BUCKET_NAME) { throw new Error("MINIO_BUCKET_NAME รจ obbligatorio nel file .env"); } const bucketName = process.env.MINIO_BUCKET_NAME; console.log("[MINIO CONFIG] Inizializzazione..."); console.log("[MINIO CONFIG] USE_SSL:", process.env.MINIO_USE_SSL); const minioConfig = { endPoint: process.env.MINIO_ENDPOINT, port: parseInt(process.env.MINIO_PORT), useSSL: process.env.MINIO_USE_SSL === "true", accessKey: process.env.MINIO_ACCESS_KEY, secretKey: process.env.MINIO_SECRET_KEY, region: process.env.MINIO_REGION, }; const minioClient = new Minio.Client(minioConfig); minioClient.bucketExists(bucketName, (err) => { if (err && err.code === "NoSuchBucket") { minioClient.makeBucket(bucketName, "us-east-1", (err) => { if (err) { console.error("Errore durante la creazione del bucket:", err); } else { console.log(`Bucket "${bucketName}" creato con successo.`); } }); } }); // Test connessione e debug /*(async () => { try { const buckets = await minioClient.listBuckets(); console.log("[DEBUG] Buckets trovati su MinIO:", buckets); } catch (error) { console.error("[DEBUG] Errore nella connessione a MinIO:", error); } })(); */ // Esportiamo sia il client che il nome del bucket module.exports = { minioClient, bucketName };