minio / minio-js

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

Incomplete type definition for getObject #1327

Closed Louis-Tian closed 4 months ago

Louis-Tian commented 4 months ago

It was mentioned here that the getObject callback's dataStream parameter have a headers property. This is not currently being reflexed in type definition.

 minioClient.getObject(buckName,objName,getOpts,(e, dataStream) =>{
    if (e) {
      return console.log(e)
    }
    dataStream.on('data', function(chunk) {
      console.log("Data. Total size = " + size,dataStream.headers)
      size += chunk.length
    })
    dataStream.on('end', function() {
      console.log("End. Total size = " + size,dataStream.headers)
    })
    dataStream.on('error', function(e) {
      console.log(e)
    })
  })

Originally posted by @prakashsvmx in https://github.com/minio/minio-js/issues/900#issuecomment-770568125

prakashsvmx commented 4 months ago

stream.Readable is from NodeJs. so it would not be appropriate to add here.

Louis-Tian commented 4 months ago

Sorry, I don't understand your point here. dataStream here clearly is not just a stream.Readable isn't it? It extends the Readable interface. Not only that typing is incomplete, the official documentation does not mention the existence of the "headers" property at all. You might argue that it's not an offical API, but in that is the case, it means the library provides no official way to fetch data and metadata from an object in a single call.