Reputation: 49
I am building a desktop app using electronjs and frontend using React, I have a table with each column having a download icon that uses the information of that row to build a URL when opened with directly download a file to your PC.
I have tried using <a href=${download_url} download><a>
works perfectly on the browser but fails to work through the electron app, it opens a file selector dialog box asking me to save the file.
I have also tried doing a window.open(url)
but that just opens an empty window, and does not download contents from the url.
How am I supposed to do download the file sent over from the URL ?
Upvotes: 1
Views: 4396
Reputation: 781
The behavior on download depends on the browser you are using. Some browsers ask where to save the file to (e.g. Mozilla Firefox), others ask for permission to save the file (e.g. Windows Edge) or just download the file with the given filename (e.g. Google Chrome by default).
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Attributes for more information on the download
attribute.
To solve your problem:
Upvotes: 4