Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PutObject: Content Type May Not Contain Charset #1007

Open
warappa opened this issue Feb 15, 2024 · 1 comment
Open

PutObject: Content Type May Not Contain Charset #1007

warappa opened this issue Feb 15, 2024 · 1 comment

Comments

@warappa
Copy link

warappa commented Feb 15, 2024

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

  • Validation of content type with an error message like "Mimetype invalid - it should be '/'"
  • Generally better exception: currently the message is only There is an error in XML document (2, 2). and inner exception only tells about an XmlSerializer error instead of the error described in the XML provided by MinIO server (<Error xmlns='http://s3.amazonaws.com/doc/2006-03-01/'> was not expected.) - I created Better Exception Messages In Case Of Server Errors #1009 for this point

Info

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

@simonthum
Copy link

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

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

No branches or pull requests

2 participants