PutObject: Content Type May Not Contain Charset
warappa opened this issue · 1 comments
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.
- Have a json file greater than about 6MB (important!)
- Configure a
PutObjectArgs
object withapplication/json; charset=utf-8
- Send it
- Error:
SignatureDoesNotMatch
- Configure content type to be
application/json
only - Send it
- 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 #1009 for this point
Info
MinIO (NuGet): 6.0.2
MinIO (Server): 2024-02-06T21:36:22Z