Open vugarli opened 3 months ago
I think the .NET SDK for the MinIO Client generates a presigned PUT URL that is incompatible with S3.
According to this, X-Amz-SignedHeaders
query parameter is for the headers that used to calculate the signature. And the format should be like "Lowercase(HeaderName) + ; + Lowercase(HeaderName)".
Below are the sample query parameter with the value generated in the wrong format and the code piece that is responsible for creating it.
X-Amz-SignedHeaders=host&aaaa=BBBB&content-length=343434&content-type=Minio.DataModel.Args.PresignedPutObjectArgs&X-Amz-Signature=1973fcfb6346941f8f848ed10a8919f39338be4febc7717cbf335e4967e87131
To make sure, I generated the same URL with the S3 SDK for .NET and observed the correct format.
I'll be opening a PR shortly to address this.
Using the above code I have generated this presigned put url:
http://localhost:9000/landingimages/1b9cdab7-60b8-4314-8faf-3edc78ee8ae5?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=UPLOADERUPLOADER%2F20240802%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240802T165608Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&aaaa=BBBB&content-length=343434&content-type=Minio.DataModel.Args.PresignedPutObjectArgs&X-Amz-Signature=1973fcfb6346941f8f848ed10a8919f39338be4febc7717cbf335e4967e87131
Upon checking the content-type param in the signed URL, I have noticed that content-type header has a rather unusual value.
To create the url
PresignedPutObjectAsync
method callsCreateRequest
extension method located inRequestExtensions.cs
file:Below is the implementation of the
CreateRequest
:My best guess is that
Convert.ToString(args.GetType(), CultureInfo.InvariantCulture)
is wrongly passed for the argumentstring contentType
.Also I didn't get why
CreateRequest
method hascontentType
as a parameter. Why not try to get it fromheaderMap
and set to default value if not found? Also, it seems likecontentType
overridesheaderMap
's Content-Type whenheaderMap
has Content-Type set, which should be the opposite?If maintainers agree, I can open PR