I am working on a task of application that runs from the web which can automatically download an executable application and place it on external media with a specified volume label. How should I start regarding I am using Flask/Python framework.
Asked
Active
Viewed 428 times
1 Answers
0
Web browsers do not let you choose where an executable gets downloaded. It would create security problems. Unless, this is a mobile progressive webapp, in which case there might be a possibility that you can ask for permissions to download the app in a specific location, but otherwise, this is not allowed.
What you can do.
You can perform a normal download, and then it would be up to the user to move the executable to the external media. This can be done by inserting the following JavaScript:
let a = document.createElement("a");
a.href = exe_data;
a.download = 'some_name.exe'
document.body.appendChild(a)
a.click();
window.URL.revokeObjectURL(a.href);
a.remove()

hostingutilities.com
- 8,894
- 3
- 41
- 51
-
I am not let the user choose where executable gets downloaded. What I want is to search for external media USB device on the PC with a specific Volume label, Ex label="EXTM". If it finds the external media with label "EXTM" it should automatically download another EXE to that location and execute. – anomalysa Sep 14 '17 at 03:50
-
A website is definitely not allowed to do that. What your proposing would allow any website to download arbitrary viruses onto a computer and execute them. – hostingutilities.com Sep 14 '17 at 03:58
-
What if a wrapper application downloaded and executed normally from the web. Then this application will search the external media and download the main exe file and execute it. shall it be a reasonable solution ? – anomalysa Sep 14 '17 at 04:17
-
That would work. In that case you might not want your wrapper application to be written in Python, as that would require the user to have Python installed, but if you do still want to go that route, one place to start would be this SO question https://stackoverflow.com/questions/8110310/simple-way-to-query-connected-usb-devices-info-in-python – hostingutilities.com Sep 14 '17 at 04:35
-
I am not restricted to specific language. What suggested language should it be written by ? – anomalysa Sep 14 '17 at 04:42
-
Any language that compiles down to an executable file should work. You could use C++, C#, Java, GoLang, Rust, etc. – hostingutilities.com Sep 14 '17 at 04:48
-
Thanks @Mr. Me for your time and help :) – anomalysa Sep 14 '17 at 05:10