DownloadItem

external class DownloadItem : EventEmitter(source)

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard
external var savePath: String

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

Functions

Link copied to clipboard
external fun addListener(type: EventType, listener: EventListener)
Link copied to clipboard
external fun cancel()

Cancels the download operation.

Link copied to clipboard
external fun canResume(): Boolean

Whether the download can resume.

Link copied to clipboard
external fun emit(type: EventType, vararg args: Any?): Boolean
Link copied to clipboard
Link copied to clipboard

The Content-Disposition field from the response header.

Link copied to clipboard

The current download speed in bytes per second.

Link copied to clipboard
external fun getEndTime(): Double

Number of seconds since the UNIX epoch when the download ended.

Link copied to clipboard
external fun getETag(): String

ETag header value.

Link copied to clipboard
external fun getFilename(): String

The file name of the download item.

Link copied to clipboard
external fun getLastModifiedTime(): String

Last-Modified header value.

Link copied to clipboard
external fun getMaxListeners(): Double
Link copied to clipboard
external fun getMimeType(): String

The files mime type.

Link copied to clipboard
external fun getPercentComplete(): Double

The download completion in percent.

Link copied to clipboard
external fun getReceivedBytes(): Double

The received bytes of the download item.

Link copied to clipboard

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

Link copied to clipboard
external fun getSavePath(): String

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
external fun getStartTime(): Double

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
external fun getTotalBytes(): Double

The total size in bytes of the download item.

Link copied to clipboard
external 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
external fun hasUserGesture(): Boolean

Whether the download has user gesture.

Link copied to clipboard
external fun isPaused(): Boolean

Whether the download is paused.

Link copied to clipboard
external fun listenerCount(type: EventType, listener: EventListener): Double
Link copied to clipboard
Link copied to clipboard
external fun off(type: EventType, listener: EventListener)
Link copied to clipboard
external fun on(type: EventType, listener: EventListener)
Link copied to clipboard
external fun once(type: EventType, listener: EventListener)
Link copied to clipboard
external fun pause()

Pauses the download.

Link copied to clipboard
external fun prependListener(type: EventType, listener: EventListener)
Link copied to clipboard
external fun prependOnceListener(type: EventType, listener: EventListener)
Link copied to clipboard
Link copied to clipboard
external fun removeAllListeners(type: EventType)
Link copied to clipboard
external fun removeListener(type: EventType, listener: EventListener)
Link copied to clipboard
external fun resume()

Resumes the download that has been paused.

Link copied to clipboard
external fun setMaxListeners(n: Number)
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
external 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.