minio / minio-dotnet

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

PutObject: Content Type May Not Contain Charset #1007

Open warappa opened 9 months ago

warappa commented 9 months ago

Using PutObjectArgs, I passed on the mime type that the ASP.NET Core request provided me. Recently, when uploading bigger json files (6MB+) I got an SignatureDoesNotMatch error (small files were still fine due to not using multipart behind the scenes).

After hours of investigating, I found out that if I pass on a value of application/json; charset=utf-8 it triggers this SignatureDoesNotMatch error. But if I cutoff the charset value and just use application/json, then it works.

I don't know if the charset would be valid under the S3 spec or not, but at least a validation of content type would be helpful.

Steps To Reproduce

Given this code:

var services = new ServiceCollection();
services.AddMinio(client =>
{
    client
        .WithCredentials("minioadmin", "minioadmin")
        .WithEndpoint("127.0.0.1", 9000)
        .WithSSL(false);
});

var serviceProvider = services.BuildServiceProvider();
var client = serviceProvider.GetRequiredService<IMinioClient>();

using var stream = File.OpenRead("test-data.json");

var putArgs = new PutObjectArgs()
    .WithBucket("spot-layouter-push")
    .WithObject("TestPut.json")
    .WithStreamData(stream)
    .WithObjectSize(stream.Length)
    .WithContentType("application/json; charset=utf-8");

await client.PutObjectAsync(putArgs);

My setup: test client (above) -> Dockerized proxy (yarp) -> Dockerized ASP.NET Core application (uploader) -> Dockerized MinIO server I think this should be reduceable to client and MinIO server only.

  1. Have a json file greater than about 6MB (important!)
  2. Configure a PutObjectArgs object with application/json; charset=utf-8
  3. Send it
  4. Error: SignatureDoesNotMatch
  5. Configure content type to be application/json only
  6. Send it
  7. No error, upload worked

Expectations

Info

MinIO (NuGet): 6.0.2 MinIO (Server): 2024-02-06T21:36:22Z

simonthum commented 9 months ago

Just a note: There is a very similar issue described in #1017, failing silently in this case.