Skip to content

fix 0 byte file upload#1387

Merged
prakashsvmx merged 1 commit intominio:masterfrom
prakashsvmx:fix-0b-file
Feb 25, 2025
Merged

fix 0 byte file upload#1387
prakashsvmx merged 1 commit intominio:masterfrom
prakashsvmx:fix-0b-file

Conversation

@prakashsvmx
Copy link
Copy Markdown
Member

@prakashsvmx prakashsvmx commented Feb 21, 2025

fix 0 byte file upload

Fixes #1386
Test Script:

Details
import * as Minio from 'minio'
import * as fs from 'fs'
import * as stream from 'stream'

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

const testUserBug = async () => {
  const destinationObject = 'empty-file'

  var metaData = {
    'Content-Type': 'text/plain',
    'X-Amz-Meta-Testing': 1234,
    example: 5678,
  }

  const filePath = '/dev/null'
  const stream = fs.createReadStream(filePath, { highWaterMark: 1024 * 1024 })
  //const { size } = await fs.promises.stat(filePath)

  // const result = await minioClient.putObject('test-bucket', destinationObject, stream, metaData)
  //console.log(result)

  let size = 0
  // Get a full object.
  const dataStream1 = await minioClient.getObject('test-bucket', destinationObject)

  dataStream1.on('data', function (chunk) {
    size += chunk.length
  })
  dataStream1.on('end', function () {
    console.log('End. Total size = ' + size)
  })
  dataStream1.on('error', function (e) {
    console.log(e)
  })
}
testUserBug()

Copy link
Copy Markdown

@grahit13 grahit13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@prakashsvmx prakashsvmx merged commit b151b68 into minio:master Feb 25, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot upload zero bytes/empty file

3 participants