Skip to content

Instantly share code, notes, and snippets.

@isc30
Last active August 26, 2018 17:41
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