Instantly share code, notes, and snippets.

Embed
What would you like to do?
downloading binary data as a file
function download_binary(binaryData, fileName, mime)
{
file = new Blob([binaryData], { type: mime });
downloadUrl = URL.createObjectURL(file);
// download the Blob
anchor = document.createElement('a');
anchor.download = fileName;
anchor.href = downloadUrl;
anchor.dataset.downloadurl = mime + ":" + fileName + ":" + downloadUrl;
document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment