Raw file downloads
-
My nodebb installation revolves around sharing files such as xml, json etc.
However, when users want to download raw files such as the uploaded xml I supplied. It's not downloading the file, seeing as its being saved as .xml. Rather it's opening the file in the browser.
Is there something I missed? If not, how can I make sure that the supported files can be downloaded rather then open in the users browser?
Ontop of that, when opening the xml in the browser nodebb is making changes to the structure of the xml, causing it to not be correct as it was before offering it as a download
-
@Drunken-Cheetah simplest way may be to update your reverse proxy so that all xml/json files from
/assets/uploads
are sent with theContent-Disposition: attachment;
header -
Thanks for the reply. I was able to solve it quickly adding it.
For anyone in the future, hosting nodebb on a windows server, may also have the same problem. This is how I fixed it
<outboundRules> <rule name="ForceFileDownload" preCondition="IsXMLorJSON"> <match serverVariable="RESPONSE_Content-Disposition" pattern=".*" /> <action type="Rewrite" value="attachment; filename={R:0}" /> </rule> <preConditions> <preCondition name="IsXMLorJSON"> <add input="{URL}" pattern="\.xml$|\.json$" /> <add input="{URL}" pattern="^/assets/uploads/" /> </preCondition> </preConditions> </outboundRules>
-