MinIo Cluster Integration With Node.Js

Minio Cluster Integration With Node.Js

Certainly! Here are detailed steps to follow for setting up and using Minio Cluster on AccuWeb.Cloud, integrating it with a Node project, and managing file uploads:
Step-by-Step Guide

Step 1. Log in to AccuWeb.Cloud Dashboard

  • Navigate to AccuWeb.Cloud: Open your web browser and go to AccuWeb.Cloud.
  • Login: Enter your credentials (username and password) to access your AccuWeb.Cloud dashboard.

Step 2. Install Minio Cluster from the Marketplace

  • Go to Marketplace: Locate and click on “Marketplace” in your AccuWeb.Cloud dashboard.
  • Search and Install Minio Cluster: In the Marketplace, search for Minio Cluster. Install it following the screenshot.

Marketplace

Step 3. Configure Minio Cluster

  • Configure Minio Cluster: After installation, configure your Minio Cluster by specifying:
    • Number of nodes (e.g., 1,16,4,8 nodes according to your requirements.)
    • Environment name (e.g., minio-cluster-ahmad)
    • Display name (e.g., Minio Cluster Ahmad)

Region (e.g., US)

Step 4. Retrieve Minio Cluster Credentials

  • Check Email: Check your registered email for the Minio Cluster admin panel URL, Get Access Key, and Secret Key provided after installation in the mail.

Step 5. Log in to Minio Cluster

  • Access Minio Cluster: Using the credentials received, login to the Minio Cluster admin panel.

URL Ref:

Access Minio Cluster

Minio Dashboard Ref:

Minio Dashboard

Step 6. Create a Bucket

  • Create Bucket: Within the Minio Cluster admin panel, create a new bucket for storing files.

Create Bucket

Step 7. Configure a Bucket & Save It

  • Configure a bucket & save It: Upload files to your created bucket. Verify successful upload by checking the file list within the bucket.

Configure Bucket

Step 8. Implement Min.io code in node js

Set Env of Min.io credentials

  • (which you get in the mail after the mini.io cluster installation):
  • MINIO_ENDPOINT=your_minio_url
  • MINIO_ACCESS_KEY=your_access_key
  • MINIO_SECRET_KEY=your_secret_key
  • MINIO_BUCKET=your_bucket_name
  • MINIO_USE_PATH_STYLE_ENDPOINT=true

Set code of server.js file


Create index.js code and write this code for uploading in API format:
const express = require('express');
const Minio = require('minio');
const multer = require('multer');
const app = express();
const PORT = 9000;
// accessing constant value, you also can access in env file like:- process.env.MINIO_ENDPOINT
const minioClient = new Minio.Client({
endPoint: "xyz.cloud",
Port:80, // use default 80 for min.io service
useSSL:false,
accessKey:"accessKey",
secretKey:"secretkey",
});
const storage = multer.memoryStorage();
const upload = multer({storage:storage});
const bucketName = "ahmadmultimedia";
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});

Call node API for uploading & Get a response of uploaded

API Uploading

View Images from min.io through API


app.get('/image/:objectName',async function(req,res){
try {
const objectName = req.params.objectName;
const stream = await minioClient.getObject(bucketName, objectName);
stream.pipe(res);
} catch (err) {
console.error('Error fetching image:', err);
res.status(500).json({ message: 'Error fetching image.', error: err });
}
});

Verify Minio dashboard for uploaded or not.

Verify Minio Dashboard