New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

electron-dl

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-dl

Simplified file downloads for your Electron app

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
145K
increased by32.51%
Maintainers
1
Weekly downloads
 
Created

What is electron-dl?

The electron-dl package is a simple and convenient way to handle file downloads in Electron applications. It provides a set of features to manage download behavior, such as saving files to specific locations, showing progress, and handling download events.

What are electron-dl's main functionalities?

Basic File Download

This feature allows you to initiate a file download from a URL. The code sample demonstrates how to use electron-dl to download a file when a navigation event occurs in a BrowserWindow.

const { app, BrowserWindow } = require('electron');
const { download } = require('electron-dl');

app.on('ready', () => {
  const win = new BrowserWindow();
  win.loadURL('https://example.com');

  win.webContents.on('will-navigate', (event, url) => {
    event.preventDefault();
    download(win, url);
  });
});

Custom Download Options

This feature allows you to customize the download process by specifying options such as the directory to save the file and a callback to track download progress. The code sample shows how to set these options.

const { app, BrowserWindow } = require('electron');
const { download } = require('electron-dl');

app.on('ready', () => {
  const win = new BrowserWindow();
  win.loadURL('https://example.com');

  win.webContents.on('will-navigate', (event, url) => {
    event.preventDefault();
    download(win, url, {
      directory: '/path/to/save',
      onProgress: (progress) => console.log(progress)
    });
  });
});

Handling Download Events

This feature provides a way to handle events related to the download process, such as completion or errors. The code sample demonstrates how to log the save path of a completed download.

const { app, BrowserWindow } = require('electron');
const { download } = require('electron-dl');

app.on('ready', () => {
  const win = new BrowserWindow();
  win.loadURL('https://example.com');

  win.webContents.on('will-navigate', (event, url) => {
    event.preventDefault();
    download(win, url).then(dl => {
      console.log('Download completed:', dl.getSavePath());
    }).catch(console.error);
  });
});

Other packages similar to electron-dl

Keywords

FAQs

Package last updated on 07 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc