Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the following function to download file:
What specific library do I need for that?
JavaScript
function OpenFile(binaryData, fileName) {
    var byteCharacters =atob(binaryData);
    var byteNumbers = new Array(byteCharacters.length);
    for (var i = 0; i < byteCharacters.length; i++) {
        byteNumbers[i] = byteCharacters.charCodeAt(i);
    }
    var byteArray = new Uint8Array(byteNumbers);
    var blob = new Blob([byteArray]);
    var link = document.createElement('a');
    link.href = window.URL.createObjectURL(blob);
    link.download = fileName;
    link.click();
}
Posted
Comments
Mostafa Asaduzzaman 27-May-15 21:32pm    
Google chrome: getting this error
Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.OpenFile
Mostafa Asaduzzaman 27-May-15 21:46pm    
I am calling OpenFile function as
onclick="OpenFile('Convert.ToBase64String(@m.FileBytes)', '@m.FileName');"
Mohibur Rashid 27-May-15 22:06pm    
if you use javascript, then just call btoa to encode, to decode atob

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900