Search code examples
node.jsamazon-s3aws-sdkminio

AWS s3 gateway with minio


I am bit confused about minio s3 gateway. Do we required aws sdk when we are running the minio server with s3 gateway? MY server started running and browsers is showing me the s3 buckets but I can't connect to the server through my node app. It is stating that port 9000 is invalid. Is that anything relevent to aws sdk or something else needs to be done here?

I have gone through the document of minio but didn't find anything for this in proper way. The docs are divided in different blocks and It doesn't stating anything like this. I've been stuck into this since 2 days. I would really grateful if someone can help me in this.

The error log as as below:

InvalidArgumentError: Invalid port : 9000,
    at new Client (/var/www/html/learn-otter-api/node_modules/minio/dist/main/minio.js:97:13)

Solution

  • The error came from the fact that minio verifies the type of every options.

    if (!(0, _helpers.isValidPort)(params.port)) {
        throw new errors.InvalidArgumentError(`Invalid port : ${params.port}`);
    }
    
    function isValidPort(port) {
      // verify if port is a number.
      if (!isNumber(port)) return false;
    ...
    

    Since it checks the port number against number type, you'll need to cast to number if you read the port number from process.env like me.

    After that you'll probably find yourself encountering another error alike, but this time the error message is more explanatory.

    if (!(0, _helpers.isBoolean)(params.useSSL)) {
        throw new errors.InvalidArgumentError(`Invalid useSSL flag type : ${params.useSSL}, expected to be of type "boolean"`);
    } // Validate region only if its set.
    

    So in case you did read options from process.env, try to cast them to the required types.

    const minioOptions = {
        "endPoint": process.env.MINIO_ENDPOINT,
        "port": 1 * process.env.MINIO_PORT,
        "useSSL": "true" === process.env.MINIO_USE_SSL,
        "accessKey": process.env.MINIO_ACCESS_KEY,
        "secretKey": process.env.MINIO_SECRET_KEY
    }