minio / minio-dotnet

MinIO Client SDK for .NET
https://docs.min.io/docs/dotnet-client-quickstart-guide.html
Apache License 2.0
575 stars 230 forks source link

[Bug] `WithContentType` has no effect if used after `WithHeaders` #1188

Open yhnavein opened 1 month ago

yhnavein commented 1 month ago

Let's consider the following code:

var metaData = new Dictionary<string, string>
    (StringComparer.Ordinal)
    {
        { "product-id", productId.ToString() }
    };
var putObjectArgs = new PutObjectArgs()
    .WithBucket("test-bucket")
    .WithObject(objectName)
    .WithObjectSize(inputStream.Length)
    .WithStreamData(inputStream)
    .WithHeaders(metaData)
    .WithContentType("image/png");

await _minioClient.PutObjectAsync(putObjectArgs, cancellationToken);

Code for me is absolutely correct, but the effect is that Content-Type of the upload file will always be application/octet-stream, where it's strictly specified to be image/png. This is as such a bug.

But apparently If I change order and make WithContentType go BEFORE WithHeaders then it will work correctly and Content-Type will be assigned as it should. So it looks like specifying WithContentType after WithHeaders has no effect and the default value will be used.