Skip to content

ElectronDownloadItem

Unofficial

Controls and reports on a file download in a session.

Import:

import type { ElectronDownloadItem } from '@obsidian-typings/obsidian-catalyst-latest';

Signature:

export interface ElectronDownloadItem

Properties

PropertyTypeDescription
savePathstringThe save file path of the download item. Only settable in the session's will-download callback.

Methods

MethodReturnsDescription
addListener(event, listener)thisRegisters a listener for the done event, emitted when the download reaches a terminal state.
addListener(event, listener)thisRegisters a listener for the updated event, emitted when the download has been updated and is not done.
cancel()voidCancels the download operation.
canResume()booleanReturns whether the download can resume.
getContentDisposition()stringReturns the Content-Disposition field from the response header.
getETag()stringReturns the ETag header value.
getFilename()stringReturns the file name of the download item.
getLastModifiedTime()stringReturns the Last-Modified header value.
getMimeType()stringReturns the file's MIME type.
getReceivedBytes()numberReturns the received bytes of the download item.
getSaveDialogOptions()ElectronSaveDialogOptionsReturns the object previously set by setSaveDialogOptions.
getSavePath()stringReturns the save path of the download item.
getStartTime()numberReturns 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()numberReturns the total size in bytes of the download item. Returns 0 if the size is unknown.
getURL()stringReturns the origin URL where the item is downloaded from.
getURLChain()string[]Returns the complete URL chain of the item including any redirects.
hasUserGesture()booleanReturns whether the download has a user gesture.
isPaused()booleanReturns whether the download is paused.
on('done', listener)thisRegisters a listener for the done event, emitted when the download reaches a terminal state.
on('updated', listener)thisRegisters a listener for the updated event, emitted when the download has been updated and is not done.
once(event, listener)thisRegisters a one-time listener for the done event.
once(event, listener)thisRegisters a one-time listener for the updated event.
pause()voidPauses the download.
removeListener(event, listener)thisRemoves a previously registered done event listener.
removeListener(event, listener)thisRemoves a previously registered updated event listener.
resume()voidResumes the download that has been paused.
setSaveDialogOptions(options)voidSets custom options for the save dialog. Only available in the session's will-download callback.
setSavePath(path)voidSets the save path of the download item. Only available in the session's will-download callback.