The Download interface, extension of Transfer

Hierarchy

Accessors

  • get transferId(): string
  • Returns

    The unique identifier for this transfer

    Example

    2ccc5d48-e43b-40b7-bb70-f591dc51c293
    

    Returns string

Methods

  • Cancel the transfer. Valid in the following states:

    • STARTING,
    • QUEUED,
    • IN_PROGRESS

    Returns

    A Promise which will resolve when the transfer has canceled successfully.

    Returns Promise<void>

  • Opens destination folder chosen during the download initialization.

    This simplifies the process of finding the downloaded file or files on transfer completion but is otherwise not required.

    This launches a finder window for Mac or an explorer window for windows

    Returns

    A Promise which will resolve when the destination folder opens in a file browser.

    Returns Promise<void>

  • Retry the incomplete transfer. Valid in the following states

    • FAILURE
    • CANCELED

    Returns

    A Promise which will resolve when the retry has been successfully initiated.

    Returns Promise<void>

  • Prompts for the destination folder for the downloaded files. This launches a native folder chooser.

    Returns

    A Promise which will resolve when the destination folder is chosen in native file chooser window

    Returns Promise<void>

  • Start the transfer. Valid in the following states:

    • IDLE

    Returns

    A Promise which will resolve when the transfer has started successfully.

    Returns Promise<void>

  • Subscribe to a transfer event. Note that all subscriptions will automatically be removed once a download has completed.

    Example

    addSubscriptions(download: Download) {
    const listener = (data: TransferEventCallbackData): Promise<void> => {
    const { transfer, transferEvent }: TransferEventCallbackData = data;
    const { type, eventData }: TransferEvent = transferEvent;
    switch (type) {
    case TransferEventType.TRANSFER_STARTED:
    //Cast to the associated type of event data
    const progressData: TransferProgressEventData = <TransferProgressEventData>eventData;
    // process as appropriate
    break;
    case TransferEventType.TRANSFER_COMPLETED:
    const completedData: TransferCompletedEventData = <TransferCompletedEventData>eventData;
    // process as appropriate
    break;
    }
    }
    download.subscribe(TransferEventType.TRANSFER_PROGRESS, startListener);
    download.subscribe(TransferEventType.TRANSFER_COMPLETED, startListener);
    }

    Parameters

    Returns void

  • Returns

    true when 1 or more listeners were removed.

    Returns boolean

Generated using TypeDoc