Consider code that (tries) to put a file to Minio:
public async Task Put(byte[] data)
{
using var ms = new MemoryStream(data);
var args = new PutObjectArgs { };
args.WithBucket("buckethead");
args.WithObject(Guid.NewGuid.ToString());
args.WithStreamData(ms);
args.WithObjectSize(ms.Length);
args.WithContentType("application/vnd.ms-excel");
await _client.PutObjectAsync(args);
}
Data is a ClosedXML XLTemplate, saved as bytes:
var template = new XLTemplate(@"D:\Documents\MyTemplate.xlsx");
template.AddVariable(myDto); //just a dto class with values to fill a template
template.Generate();
using var ms = new MemoryStream();
template.SaveAs(ms);
return ms.ToArray();
Problems is, this line:
await _client.PutObjectAsync(args);
Fails with the following:
{"There is an error in XML document (0, 0)."}
For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlReader.MoveToContent()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderErrorResponse.Read3_Error()
What does it have to do with serialization and how to fix it?
Btw created XLTemplate is legit, if saved to hard drive as .xlsx I can open it just fine.