Prevent downloads #512

Open
opened 2026-01-29 16:41:40 +00:00 by claunia · 3 comments
Owner

Originally created by @Elimil on GitHub (Jun 13, 2020).

Would it be possible to get the will-download event to Session class?
I would want to prevent certain file extensions to be downloaded.
Another thing would be that could do automation with specific filetypes.
More information of this at
https://github.com/electron/electron/blob/master/docs/api/download-item.md

Originally created by @Elimil on GitHub (Jun 13, 2020). Would it be possible to get the will-download event to Session class? I would want to prevent certain file extensions to be downloaded. Another thing would be that could do automation with specific filetypes. More information of this at https://github.com/electron/electron/blob/master/docs/api/download-item.md
claunia added the help wantedFeature labels 2026-01-29 16:41:40 +00:00
Author
Owner

@Saviorjke commented on GitHub (Nov 19, 2020):

What about to get the Event: 'will-navigate'? https://github.com/electron/electron/blob/master/docs/api/web-contents.md
It would be helpful to have some kind of events of this class.

@Saviorjke commented on GitHub (Nov 19, 2020): What about to get the Event: 'will-navigate'? https://github.com/electron/electron/blob/master/docs/api/web-contents.md It would be helpful to have some kind of events of this class.
Author
Owner

@GregorBiswanger commented on GitHub (Jul 2, 2021):

We need support - I can't add new features as quickly as possible on my own. Here is a video of how you can install the missing features yourself and submit them as a pull request:
https://youtu.be/Po-saU_Z6Ws

Please also test it with you.

@GregorBiswanger commented on GitHub (Jul 2, 2021): We need support - I can't add new features as quickly as possible on my own. Here is a video of how you can install the missing features yourself and submit them as a pull request: https://youtu.be/Po-saU_Z6Ws Please also test it with you.
Author
Owner

@FlorianRappl commented on GitHub (Nov 6, 2025):

The problem is that the event args provide methods - and these method need to be called synchronously. So I am not sure that we can actually handle it / provide this (in the referenced way, i.e., via an event handler that - when triggered - calls the setSavePath method).

What we might do is introduce an API that essentially once listens, then already sets it (so you provide something like StoreNextDownloadTo or use a helper function that triggers the download and once listens - with the logic already pre-given and not computed when the event occurs).

Somebody wants to take this issue?

@FlorianRappl commented on GitHub (Nov 6, 2025): The problem is that the event args provide methods - and these method need to be called synchronously. So I am not sure that we can actually handle it / provide this (in the referenced way, i.e., via an event handler that - when triggered - calls the `setSavePath` method). What we might do is introduce an API that essentially *once* listens, then already sets it (so you provide something like `StoreNextDownloadTo` or use a helper function that triggers the download and *once* listens - with the logic already pre-given and not computed when the event occurs). Somebody wants to take this issue?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#512