Nomenjanahary's avatar

Minio

Expected Behavior

Minio should be able to connect in JS.

Current Behavior

Error: connect ETIMEDOUT 185.172.100.60:9000
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)

Steps to Reproduce (for bugs)

host a server with jelastic cloud, connect with new minio client

Context

trying to upload a file using node.js

Environment

  • Minio : RELEASE.2021-04-22T15-44-28Z
  • Linux
  • Linux XXXXXXXXXX 4.18.0-1127.18.2.vz7.163.46 #1 SMP Fri Nov 20 21:47:55 MSK 2020 x86_64 x86_64 x86_64 GNU/Linux
const Express = require("express");
const app = Express()
const multer = require('multer')
const Minio = require('minio')



//set up minio config

const minioClient = new Minio.Client({
    accessKey: 'XXXXX',
    secretKey: 'XXXXXX',
    endPoint: 'XXXXXX',
    useSSL: true,
    port: 9000
})



const readOnlyAnonUserPolicy = {
    "Version": "2012-10-17",
    "Statement": [{
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:ListBucket",
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::bucket",
                "arn:aws:s3:::bucket/*"
            ]
        },
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:ListBucket",
                "s3:PutObject",
            ],
            "Resource": [
                "arn:aws:s3:::bucket",
                "arn:aws:s3:::bucket/*"
            ]
        }
    ]
}



minioClient.setBucketPolicy('bucket', JSON.stringify(readOnlyAnonUserPolicy), function(err) {
    if (err) throw err
    console.log('Bucket policy set')
});




const metaData = {
    'Content-Type': '*',
    'Content-Language': 123,
    'X-Amz-Meta-Testing': 1234,
    'example': 5678
}

app.post('/upload', multer({ storage: multer.memoryStorage() }).single("file"), (req, res, next) => {
    const file = req.file
    if (!file) {
        const error = new Error('Please upload a file')
        error.httpStatusCode = 400
        return next(error)
    }


    var originalname = file.originalname.split(' ');
    const fileName = 'IMG_' + Date.now() + '_' + originalname.join('_');

    minioClient.putObject('bucket', fileName, file.buffer, (err, etag) => {
        if (err) throw err
        return res.json(fileName)
    })
})

and i have this error

Error: connect ETIMEDOUT XXXXX:9000
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
  errno: -60,
  code: 'ETIMEDOUT',
  syscall: 'connect',
  address: 'XXXXX',
  port: 9000
}

NB : My access key , secret key and endPoint are correct

0 likes
0 replies

Please or to participate in this conversation.