Saves an octet-stream returned from a REST call as a file
var toSend = {}; | |
var xmlhttp = new XMLHttpRequest(); | |
xmlhttp.open("POST", "https://myserver.com/path", true); | |
xmlhttp.responseType="blob"; | |
xmlhttp.setRequestHeader("Content-Type", "application/json"); | |
xmlhttp.overrideMimeType('application/octet-stream'); | |
xmlhttp.onload = function() { | |
console.log('success'); | |
console.log(xmlhttp.response); | |
window.open(URL.createObjectURL(xmlhttp.response)).focus(); | |
}; | |
xmlhttp.send(JSON.stringify(toSend)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment