You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 calls CreateRequest extension method located in RequestExtensions.cs file:
internal static async Task<HttpRequestMessageBuilder> CreateRequest(this IMinioClient minioClient,
HttpMethod method,
string bucketName = null,
string objectName = null,
IDictionary<string, string> headerMap = null,
string contentType = "application/octet-stream",
ReadOnlyMemory<byte> body = default,
string resourcePath = null,
bool isBucketCreationRequest = false)
{
.....
if (headerMap is not null)
{
if (headerMap.TryGetValue(messageBuilder.ContentTypeKey, out var value) && !string.IsNullOrEmpty(value))
headerMap[messageBuilder.ContentTypeKey] = contentType;
foreach (var entry in headerMap) messageBuilder.AddOrUpdateHeaderParameter(entry.Key, entry.Value);
}
return messageBuilder;
}
My best guess is that Convert.ToString(args.GetType(), CultureInfo.InvariantCulture) is wrongly passed for the argument string contentType.
Also I didn't get why CreateRequest method has contentType as a parameter. Why not try to get it from headerMap and set to default value if not found? Also, it seems like contentType overrides headerMap's Content-Type when headerMap has Content-Type set, which should be the opposite?
If maintainers agree, I can open PR
The text was updated successfully, but these errors were encountered:
vugarli
changed the title
Content-Type header not included in the signed url
Content-Type header value is wrong in the presigned put url
Aug 2, 2024
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.
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
The text was updated successfully, but these errors were encountered: