Header menu logo fable-electron-docs-api

DownloadItem Type

⚠ Process Availability: Main ✔ | Renderer ❌ | Utility ❌ | Exported ❌

Instance members

Instance member Description

this.canResume ()

Full Usage: this.canResume ()

Returns: bool
Modifiers: inline

Whether the download can resume.

Returns: bool

this.cancel ()

Full Usage: this.cancel ()

Modifiers: inline

Cancels the download operation.

this.getContentDisposition ()

Full Usage: this.getContentDisposition ()

Returns: string
Modifiers: inline

The Content-Disposition field from the response header.

Returns: string

this.getCurrentBytesPerSecond ()

Full Usage: this.getCurrentBytesPerSecond ()

Returns: int
Modifiers: inline

The current download speed in bytes per second.

Returns: int

this.getETag ()

Full Usage: this.getETag ()

Returns: string
Modifiers: inline

ETag header value.

Returns: string

this.getEndTime ()

Full Usage: this.getEndTime ()

Returns: double
Modifiers: inline

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

Returns: double

this.getFilename ()

Full Usage: this.getFilename ()

Returns: string
Modifiers: inline

The file name of the download item.> [!NOTE] The file name is not always the same as the actual one saved in local disk. If user changes the file name in a prompted download saving dialog, the actual name of saved file will be different.

Returns: string

this.getLastModifiedTime ()

Full Usage: this.getLastModifiedTime ()

Returns: string
Modifiers: inline

Last-Modified header value.

Returns: string

this.getMimeType ()

Full Usage: this.getMimeType ()

Returns: string
Modifiers: inline

The files mime type.

Returns: string

this.getPercentComplete ()

Full Usage: this.getPercentComplete ()

Returns: int
Modifiers: inline

The download completion in percent.

Returns: int

this.getReceivedBytes ()

Full Usage: this.getReceivedBytes ()

Returns: int
Modifiers: inline

The received bytes of the download item.

Returns: int

this.getSaveDialogOptions ()

Full Usage: this.getSaveDialogOptions ()

Returns: obj
Modifiers: inline

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

Returns: obj

this.getSavePath ()

Full Usage: this.getSavePath ()

Returns: string
Modifiers: inline

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.

Returns: string

this.getStartTime ()

Full Usage: this.getStartTime ()

Returns: double
Modifiers: inline

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

Returns: double

this.getState ()

Full Usage: this.getState ()

Returns: GetState
Modifiers: inline

The current state. Can be progressing, completed, cancelled or interrupted.> [!NOTE] The following methods are useful specifically to resume a cancelled item when session is restarted.

Returns: GetState

this.getTotalBytes ()

Full Usage: this.getTotalBytes ()

Returns: int
Modifiers: inline

The total size in bytes of the download item.If the size is unknown, it returns 0.

Returns: int

this.getURL ()

Full Usage: this.getURL ()

Returns: string
Modifiers: inline

The origin URL where the item is downloaded from.

Returns: string

this.getURLChain ()

Full Usage: this.getURLChain ()

Returns: string[]
Modifiers: inline

The complete URL chain of the item including any redirects.

Returns: string[]

this.hasUserGesture ()

Full Usage: this.hasUserGesture ()

Returns: bool
Modifiers: inline

Whether the download has user gesture.

Returns: bool

this.isPaused ()

Full Usage: this.isPaused ()

Returns: bool
Modifiers: inline

Whether the download is paused.

Returns: bool

this.offDone handler

Full Usage: this.offDone handler

Parameters:
Modifiers: inline

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.The state can be one of following:* completed - The download completed successfully.* cancelled - The download has been cancelled.* interrupted - The download has interrupted and can not resume.

handler : IOnDone -> unit

this.offDone handler

Full Usage: this.offDone handler

Parameters:
Modifiers: inline

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.The state can be one of following:* completed - The download completed successfully.* cancelled - The download has been cancelled.* interrupted - The download has interrupted and can not resume.

handler : Event -> State -> unit

this.offUpdated handler

Full Usage: this.offUpdated handler

Parameters:
Modifiers: inline

Emitted when the download has been updated and is not done.The state can be one of following:* progressing - The download is in-progress.* interrupted - The download has interrupted and can be resumed.

handler : IOnUpdated -> unit

this.offUpdated handler

Full Usage: this.offUpdated handler

Parameters:
Modifiers: inline

Emitted when the download has been updated and is not done.The state can be one of following:* progressing - The download is in-progress.* interrupted - The download has interrupted and can be resumed.

handler : Event -> State -> unit

this.onDone handler

Full Usage: this.onDone handler

Parameters:
Modifiers: inline

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.The state can be one of following:* completed - The download completed successfully.* cancelled - The download has been cancelled.* interrupted - The download has interrupted and can not resume.

handler : IOnDone -> unit

this.onDone handler

Full Usage: this.onDone handler

Parameters:
Modifiers: inline

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.The state can be one of following:* completed - The download completed successfully.* cancelled - The download has been cancelled.* interrupted - The download has interrupted and can not resume.

handler : Event -> State -> unit

this.onUpdated handler

Full Usage: this.onUpdated handler

Parameters:
Modifiers: inline

Emitted when the download has been updated and is not done.The state can be one of following:* progressing - The download is in-progress.* interrupted - The download has interrupted and can be resumed.

handler : IOnUpdated -> unit

this.onUpdated handler

Full Usage: this.onUpdated handler

Parameters:
Modifiers: inline

Emitted when the download has been updated and is not done.The state can be one of following:* progressing - The download is in-progress.* interrupted - The download has interrupted and can be resumed.

handler : Event -> State -> unit

this.onceDone handler

Full Usage: this.onceDone handler

Parameters:
Modifiers: inline

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.The state can be one of following:* completed - The download completed successfully.* cancelled - The download has been cancelled.* interrupted - The download has interrupted and can not resume.

handler : IOnDone -> unit

this.onceDone handler

Full Usage: this.onceDone handler

Parameters:
Modifiers: inline

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.The state can be one of following:* completed - The download completed successfully.* cancelled - The download has been cancelled.* interrupted - The download has interrupted and can not resume.

handler : Event -> State -> unit

this.onceUpdated handler

Full Usage: this.onceUpdated handler

Parameters:
Modifiers: inline

Emitted when the download has been updated and is not done.The state can be one of following:* progressing - The download is in-progress.* interrupted - The download has interrupted and can be resumed.

handler : IOnUpdated -> unit

this.onceUpdated handler

Full Usage: this.onceUpdated handler

Parameters:
Modifiers: inline

Emitted when the download has been updated and is not done.The state can be one of following:* progressing - The download is in-progress.* interrupted - The download has interrupted and can be resumed.

handler : Event -> State -> unit

this.pause ()

Full Usage: this.pause ()

Modifiers: inline

Pauses the download.

this.resume ()

Full Usage: this.resume ()

Modifiers: inline

Resumes the download that has been paused.> [!NOTE] To enable resumable downloads the server you are downloading from must support range requests and provide both Last-Modified and ETag header values. Otherwise resume() will dismiss previously received bytes and restart the download from the beginning.

this.savePath

Full Usage: this.savePath

A string property that determines the save file path of the download item.The property is only available in session's will-download callback function. If user doesn't set the save path via the property, Electron will use the original routine to determine the save path; this usually prompts a save dialog.

this.setSaveDialogOptions options

Full Usage: this.setSaveDialogOptions options

Parameters:
    options : obj

Modifiers: inline

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.

options : obj

this.setSavePath path

Full Usage: this.setSavePath path

Parameters:
    path : string

Modifiers: inline

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.

path : string

Type something to start searching.