-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save on client side file corrupted #33
Comments
@sunojvijayan Hi, I am also facing same issue. If you got any solution please share. |
Hi I was not able to do this in one go. So I saved the file to the server and then gave the link to the client side for the user to download. |
Hi, after struggling a lot, finally i got the solution. I have followed the below approach :
In my case, 'corrupt file' error was shown while i was sending file data before completion of write file method. To resolve this, i write read file code in callback of writeFile function and send that response to front-end. Hope this will help. |
Any efficient solution to this? |
We apply the following preprocessing of the data from json2xls before creating the anchor element as per @sunojvijayan code above. const decoded = decodeBase64(data); const blob = new Blob([buf], { |
From server I am using this to send the file to client.
response.xls('data.xlsx', jsonArr, 'binary');
In client I am using this to download file.
var blob = new Blob([result.data], { //type: 'application/vnd.ms-excel' type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' //type: 'binary' }); var a = document.createElement('a'); var url = URL.createObjectURL(blob); a.href = url; a.download = "sss" //yourfilename a.target = '_blank'; document.body.appendChild(a); a.click();
It downloads the file. But when I open the file, it says corrupt.
Please help.
The text was updated successfully, but these errors were encountered: