I am receiving an XML file from an app. I have to take the content of that file and copy paste it into my own xml file. The way I do that is by GetBufferedInputStream()
and copy that to the new file bestelling.xml
My POST Api:
public string Post()
{
var result = "";
if (Request.Content != null)
{
string map = @"D:\bestelApp\bestelApp\Content\bestellingen\ontvangen";
string count = Directory.GetFiles(map, "*.xml").Count().ToString();
string extention = ".xml";
string fileName = "bestelling" + (count != "0" ? count : "") + extention;
string path = map + "//" + fileName;
using (Stream output = File.OpenWrite(path))
{
using (Stream input = HttpContext.Current.Request.GetBufferedInputStream())
{
input.CopyTo(output);
}
}
result = new bestellingenController().ConvertXmlToObj(fileName, path);
}
return result;
}
but when Copying the file's entity body to my own file, it copies more than exists in the original file.
Original file's content simply holds xml:
<xml?version=1.0>...</xml>
While the new file's content suddenly has some extra info and between that the xml:
-----------------------8d618bbd8fc0d89
Content-Disposition: form-data; name="file"; filename="14_20180912134640.xml"
Content-Type: application/octet-stream
<xml?version=1.0>...</xml>
-----------------------86d18bbd8fc0d89--
I just want the xml copied... What causes this and how do I solve this?
EDIT Looks like ChristianMurschall's hunch was correct because it IS the header that's being added into the body. but how do I exclude the header from the content?