DownloadItem

external class DownloadItem : EventEmitter(source)

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

A string property that determines the save file path of the download item.

Functions

Link copied to clipboard
fun addListener(event: DownloadItemEvent.DONE, listener: (event: Event<*>, state: DownloadItemDoneListenerState) -> Unit)
Link copied to clipboard
fun cancel()

Cancels the download operation.

Link copied to clipboard

Whether the download can resume.

Link copied to clipboard
Link copied to clipboard

The Content-Disposition field from the response header.

Link copied to clipboard

ETag header value.

Link copied to clipboard

The file name of the download item.

Link copied to clipboard

Last-Modified header value.

Link copied to clipboard
Link copied to clipboard

The files mime type.

Link copied to clipboard

The received bytes of the download item.

Link copied to clipboard

Returns the object previously set by downloadItem.setSaveDialogOptions(options).

Link copied to clipboard

The save path of the download item. This will be either the path set via downloadItem.setSavePath(path) or the path selected from the shown save dialog.

Link copied to clipboard

Number of seconds since the UNIX epoch when the download was started.

Link copied to clipboard

The current state. Can be progressing, completed, cancelled or interrupted.

Link copied to clipboard

The total size in bytes of the download item.

Link copied to clipboard
fun getURL(): String

The origin URL where the item is downloaded from.

Link copied to clipboard

The complete URL chain of the item including any redirects.

Link copied to clipboard

Whether the download has user gesture.

Link copied to clipboard

Whether the download is paused.

Link copied to clipboard
fun off(event: DownloadItemEvent.DONE, listener: (event: Event<*>, state: DownloadItemDoneListenerState) -> Unit)
fun off(event: DownloadItemEvent.UPDATED, listener: (event: Event<*>, state: DownloadItemUpdatedListenerState) -> Unit)
Link copied to clipboard
fun on(event: DownloadItemEvent.DONE, listener: (event: Event<*>, state: DownloadItemDoneListenerState) -> Unit)

Emitted when the download is in a terminal state. This includes a completed download, a cancelled download (via downloadItem.cancel()), and interrupted download that can't be resumed.

fun on(event: DownloadItemEvent.UPDATED, listener: (event: Event<*>, state: DownloadItemUpdatedListenerState) -> Unit)

Emitted when the download has been updated and is not done.

Link copied to clipboard
fun once(event: DownloadItemEvent.DONE, listener: (event: Event<*>, state: DownloadItemDoneListenerState) -> Unit)
fun once(event: DownloadItemEvent.UPDATED, listener: (event: Event<*>, state: DownloadItemUpdatedListenerState) -> Unit)
Link copied to clipboard
fun pause()

Pauses the download.

Link copied to clipboard
Link copied to clipboard
fun resume()

Resumes the download that has been paused.

Link copied to clipboard
Link copied to clipboard

This API allows the user to set custom options for the save dialog that opens for the download item by default. The API is only available in session's will-download callback function.

Link copied to clipboard
fun setSavePath(path: String)

The API is only available in session's will-download callback function. If path doesn't exist, Electron will try to make the directory recursively. If user doesn't set the save path via the API, Electron will use the original routine to determine the save path; this usually prompts a save dialog.