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
WithContentType(string type) accepts any string its given, but it should not.
It had for us the side effect of breaking the MultiPart upload of large files (> 5MB).
It was very hard to debug, because the error we got was an XML inside the Library : (sensitive info blanked with "---")
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><Key>---</Key>
<BucketName>---</BucketName>
<Resource>---</Resource>
<RequestId>182801E71B31948E</RequestId>
<HostId>---</HostId>
</Error>
Issue 2
It was even harder to debug because of the stack.
"System.InvalidOperationException: There is an error in XML document (2, 2).\n ---> System.InvalidOperationException: <Error xmlns='http://s3.amazonaws.com/doc/2006-03-01/'> was not expected.\n
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderInitiateMultipartUploadResult.Read3_InitiateMultipartUploadResult()\n
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)\n
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)\n --- End of inner exception stack trace ---\n
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)\n
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)\n
at Minio.Helper.Utils.DeserializeXml[T](Stream stream)\n
at Minio.DataModel.Response.NewMultipartUploadResponse..ctor(HttpStatusCode statusCode, String responseContent)\n
at Minio.MinioClient.NewMultipartUploadAsync(NewMultipartUploadPutArgs args, CancellationToken cancellationToken)\n
at Minio.MinioClient.PutObjectAsync(PutObjectArgs args, CancellationToken cancellationToken)\n
XML deserialization error indicates another issue in the code.
It is located here :
The code returns an empty stream. DeserializeXml<T>(Stream stream) returns a default InitiateMultipartUploadResult, that ends up throwing because the namespace is not recognized.
Proposed fixes
Create an Enum / Use an existing Enum from .net to enforce the ContentType
Read the response content like await response.Content.ReadAsStingAsync(), and use the result inside your exising method DeserializeXml<T>(string xml) (the one taking string, not stream)
Overall better exceptions based on the content of the XML, because it's very time consuming to find the actual issue
These issues were experienced using the latest version of the nuget package to this date, 6.0.4.
The text was updated successfully, but these errors were encountered:
Summary : Be more strict about what "ContentType" can be passed as an argument to PutObjectArgs
Issue 1 - Content type
See the problematic code we had :
WithContentType(string type)
accepts any string its given, but it should not.It had for us the side effect of breaking the MultiPart upload of large files (> 5MB).
It was very hard to debug, because the error we got was an XML inside the Library : (sensitive info blanked with "---")
Issue 2
It was even harder to debug because of the stack.
XML deserialization error indicates another issue in the code.
It is located here :
The code returns an empty stream.
DeserializeXml<T>(Stream stream)
returns a default InitiateMultipartUploadResult, that ends up throwing because the namespace is not recognized.Proposed fixes
await response.Content.ReadAsStingAsync()
, and use the result inside your exising methodDeserializeXml<T>(string xml)
(the one takingstring
, notstream
)These issues were experienced using the latest version of the nuget package to this date, 6.0.4.
The text was updated successfully, but these errors were encountered: