minio / minio-js

MinIO Client SDK for Javascript
https://docs.min.io/docs/javascript-client-quickstart-guide.html
Apache License 2.0
920 stars 271 forks source link

Error uploading files to minio #1270

Closed kusaljr closed 5 months ago

kusaljr commented 5 months ago

When i try uploading file to minio it throws this error

image

i'm using minio client version 7.1.3

harshavardhana commented 5 months ago

@kusaljr what is your endpoint pointing to ?

kusaljr commented 5 months ago
image

this is my minio client configuration, when i try doing other operations like list buckets, files, it works but when i try uploading file it gives me that parseError

@harshavardhana

prakashsvmx commented 5 months ago

What is the method used for uploading ? Please share the piece of code that actually does the putObject or fPutObject @kusaljr

mc admin trace <ALIAS> -v would also be helpful.

kusaljr commented 5 months ago

this it the code:

image

this is my image object that i was trying to upload

image

@prakashsvmx

prakashsvmx commented 5 months ago

I have tried the below with "minio": "^7.1.3" it looks fine..

code can be found in https://github.com/prakashsvmx/mino-js-consumer/pull/1

var Minio = require('minio')
var Fs = require('fs')

var minioClient = new Minio.Client({
    endPoint: 'localhost',
    port: 22000,
    useSSL: false,
    accessKey: 'minio',
    secretKey: 'minio123'
});

var file = "/home/prakash/Pictures/1.png"

  var fileStream = Fs.createReadStream(file)
  var metadata = {
    "content-type": '' // testing
  }
  var fileStat = Fs.stat(file, function(err, stats) {
    if(err) { 
      return console.log('error') 
    }
    minioClient.putObject("test-bucket", "1.png", fileStream, stats.size,
    function(err, objectInfo) {
      if (err) return console.log(err);
      console.log("File uploaded successfully1.", objectInfo);
    })
  })
 ➜ node api-tests/put-image.js

File uploaded successfully1. {
  etag: 'c1e890bca092ccffa92312b21423872d',
  versionId: 'a22b907f-a752-43d8-97a2-1a7e6e4064fa'
}

 ➜ mc ls local22/test-bucket/1.png --versions                                                  
[2024-03-11 10:18:24 IST] 164KiB STANDARD a22b907f-a752-43d8-97a2-1a7e6e4064fa v2 PUT 1.png
[2024-03-11 10:18:03 IST] 164KiB STANDARD 37f98b75-d064-47ef-92a9-8c525a0b0331 v1 PUT 1.png

are you running in browser or node environment? what is the node version used ?

harshavardhana commented 5 months ago
image

this is my minio client configuration, when i try doing other operations like list buckets, files, it works but when i try uploading file it gives me that parseError

@harshavardhana

Are you sure you are using the right endpoint and not passing Console UI URL?