Skip to main content

downloads

Enables extensions to interact with the browser's download manager. You can use this API module to download files, cancel, pause, resume downloads, and show downloaded files in the file manager.

To use this API you need to have the "downloads" API permission specified in your manifest.json file.

Types

  • {{WebExtAPIRef("downloads.FilenameConflictAction")}}
    • : Defines options for what to do if the name of a downloaded file conflicts with an existing file.
  • {{WebExtAPIRef("downloads.InterruptReason")}}
    • : Defines a set of possible reasons why a download was interrupted.
  • {{WebExtAPIRef("downloads.DangerType")}}
    • : Defines a set of common warnings of possible dangers associated with downloadable files.
  • {{WebExtAPIRef("downloads.State")}}
    • : Defines different states that a current download can be in.
  • {{WebExtAPIRef("downloads.DownloadItem")}}
    • : Represents a downloaded file.
  • {{WebExtAPIRef("downloads.StringDelta")}}
    • : Represents the difference between two strings.
  • {{WebExtAPIRef("downloads.DoubleDelta")}}
    • : Represents the difference between two doubles.
  • {{WebExtAPIRef("downloads.BooleanDelta")}}
    • : Represents the difference between two booleans.
  • {{WebExtAPIRef("downloads.DownloadTime")}}
    • : Represents the time a download took to complete.
  • {{WebExtAPIRef("downloads.DownloadQuery")}}
    • : Defines a set of parameters that can be used to search the downloads manager for a specific set of downloads.

Functions

  • {{WebExtAPIRef("downloads.download()")}}
    • : Downloads a file, given its URL and other optional preferences.
  • {{WebExtAPIRef("downloads.search()")}}
    • : Queries the {{WebExtAPIRef("downloads.DownloadItem", "DownloadItems")}} available in the browser's downloads manager, and returns those that match the specified search criteria.
  • {{WebExtAPIRef("downloads.pause()")}}
    • : Pauses a download.
  • {{WebExtAPIRef("downloads.resume()")}}
    • : Resumes a paused download.
  • {{WebExtAPIRef("downloads.cancel()")}}
    • : Cancels a download.
  • {{WebExtAPIRef("downloads.getFileIcon()")}}
    • : Retrieves an icon for the specified download.
  • {{WebExtAPIRef("downloads.open()")}}
    • : Opens the downloaded file with its associated application.
  • {{WebExtAPIRef("downloads.show()")}}
    • : Opens the platform's file manager application to show the downloaded file in its containing folder.
  • {{WebExtAPIRef("downloads.showDefaultFolder()")}}
    • : Opens the platform's file manager application to show the default downloads folder.
  • {{WebExtAPIRef("downloads.erase()")}}
    • : Erases matching {{WebExtAPIRef("downloads.DownloadItem", "DownloadItems")}} from the browser's download history, without deleting the downloaded files from disk.
  • {{WebExtAPIRef("downloads.removeFile()")}}
    • : Removes a downloaded file from disk, but not from the browser's download history.
  • {{WebExtAPIRef("downloads.acceptDanger()")}}
    • : Prompts the user to accept or cancel a dangerous download.
  • {{WebExtAPIRef("downloads.setShelfEnabled()")}}
    • : Enables or disables the gray shelf at the bottom of every window associated with the current browser profile. The shelf will be disabled as long as at least one extension has disabled it.

Events

  • {{WebExtAPIRef("downloads.onCreated")}}
    • : Fires with the {{WebExtAPIRef("downloads.DownloadItem", "DownloadItem")}} object when a download begins.
  • {{WebExtAPIRef("downloads.onErased")}}
    • : Fires with the downloadId when a download is erased from history.
  • {{WebExtAPIRef("downloads.onChanged")}}
    • : When any of a {{WebExtAPIRef("downloads.DownloadItem", "DownloadItem")}}'s properties except bytesReceived changes, this event fires with the downloadId and an object containing the properties that changed.

Browser compatibility

{{WebExtExamples("h2")}}

[!NOTE] This API is based on Chromium's chrome.downloads API.