Add a comment. Active Oldest Votes. Improve this answer. That doesn't solve my problem since it just prints the file content to the console. I need to tell it somehow to let the browser handle the download It worked although in a kind of a hackish way: first chrome's popup blocker blocked the click, then when I allowed popups, it opened the download in a new window. Is there anyway to make it more pleasant? On Mozilla Firefox is not working To get it work on Mozilla Firefox, attach your anchor to document: angular.
Show 12 more comments. Here's another solution I found that works in Angular and is very straighforward. Community Bot 1 1 1 silver badge. Komal Singh Komal Singh 5 5 silver badges 19 19 bronze badges. Thank you for this answer. This one does work in Chrome and Firefox. Which version of each browser? This is genius. The technique can be used to download arbitrary data from angular as a file. Show 1 more comment. Nilath Nilath 2 2 silver badges 8 8 bronze badges. Using angular 1. Adam Prax 6, 3 3 gold badges 28 28 silver badges 31 31 bronze badges.
The Overflow Blog. Podcast Who is building clouds for the independent developer? Exploding turkeys and how not to thaw your frozen bird: Top turkey questions Featured on Meta. Now live: A fully responsive profile. Reducing the weight of our footer. Linked See more linked questions. I am trying to download a zip file from my server spring mvc controller.
Above code works, but I need to give file name which I am getting in the response header. I got the file name from header 'Content-Disposition' how to use this file name to downloaded file? When uploading files to the server it goes great; no damaged files. However when i download files other than pure txt:s they woork they grow in size and become corrupt. After alot of investigation I dont know what could be wrong. Im simply writing the file as a stream to the response and downloading the blob.
Any ideas are welcome! I have some text in a hidden textarea. When a button is clicked I would like to have the text offered for download as a.
0コメント