I am attempting to download 'Open Document Format' files from a node.js application which is being converted/exported through Open Office on the server (HTML to various formats). This works great for PDF, Text, HTML, Word etc. but does not work with documents exported as ODF. Converting and downloading the same files directly through the web application front-end works fine; downloading through XMLHTTP and saving to disk using ADO corrupts the document for some reason.
Here is my function:
Public Function downloadExport(fileToDownload, saveToPath)
Dim xmlhttp, ostream As Object
Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
Set ostream = CreateObject("Adodb.Stream")
xmlhttp.setOption(2) = 13056
xmlhttp.open "GET", fileToDownload, False
'Cookie headers are correct
xmlhttp.setRequestHeader "Cookie", "sessionID=Arrays.4Qqu2s32xQQyZA4"
xmlhttp.setRequestHeader "Cookie", "express_sid=s%3ADHclQm7vYT1Ixa2SD2wjk"
xmlhttp.send
ostream.Type = 1
ostream.open
ostream.write xmlhttp.responseBody
ostream.SaveToFile saveToPath, 1
ostream.Close
Set ostream = Nothing
Set xmlhttp = Nothing
End Function
Thank you EOF