ElectronDownloadItem
Unofficial
Controls and reports on a file download in a session.
Import:
import type { ElectronDownloadItem } from '@obsidian-typings/obsidian-public-latest';Signature:
export interface ElectronDownloadItemProperties
| Property | Type | Description | |
|---|---|---|---|
| savePath | string | The save file path of the download item. Only settable in the session's will-download callback. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| addListener(event, listener) | this | Registers a listener for the done event, emitted when the download reaches a terminal state. | |
| addListener(event, listener) | this | Registers a listener for the updated event, emitted when the download has been updated and is not done. | |
| cancel() | void | Cancels the download operation. | |
| canResume() | boolean | Returns whether the download can resume. | |
| getContentDisposition() | string | Returns the Content-Disposition field from the response header. | |
| getETag() | string | Returns the ETag header value. | |
| getFilename() | string | Returns the file name of the download item. | |
| getLastModifiedTime() | string | Returns the Last-Modified header value. | |
| getMimeType() | string | Returns the file's MIME type. | |
| getReceivedBytes() | number | Returns the received bytes of the download item. | |
| getSaveDialogOptions() | ElectronSaveDialogOptions | Returns the object previously set by setSaveDialogOptions. | |
| getSavePath() | string | Returns the save path of the download item. | |
| getStartTime() | number | Returns the number of seconds since the UNIX epoch when the download was started. | |
| getState() | 'cancelled' | 'completed' | 'interrupted' | 'progressing' | Returns the current state of the download. | |
| getTotalBytes() | number | Returns the total size in bytes of the download item. Returns 0 if the size is unknown. | |
| getURL() | string | Returns the origin URL where the item is downloaded from. | |
| getURLChain() | string[] | Returns the complete URL chain of the item including any redirects. | |
| hasUserGesture() | boolean | Returns whether the download has a user gesture. | |
| isPaused() | boolean | Returns whether the download is paused. | |
| on('done', listener) | this | Registers a listener for the done event, emitted when the download reaches a terminal state. | |
| on('updated', listener) | this | Registers a listener for the updated event, emitted when the download has been updated and is not done. | |
| once(event, listener) | this | Registers a one-time listener for the done event. | |
| once(event, listener) | this | Registers a one-time listener for the updated event. | |
| pause() | void | Pauses the download. | |
| removeListener(event, listener) | this | Removes a previously registered done event listener. | |
| removeListener(event, listener) | this | Removes a previously registered updated event listener. | |
| resume() | void | Resumes the download that has been paused. | |
| setSaveDialogOptions(options) | void | Sets custom options for the save dialog. Only available in the session's will-download callback. | |
| setSavePath(path) | void | Sets the save path of the download item. Only available in the session's will-download callback. |