Use the chrome.downloads API to programmatically initiate, monitor, fudge, and search for downloads. You can find childlike examples of using the chrome.downloads API in the examples/api/downloads directory. For other examples and for help in viewing the generator code, see Samples. You must declare the “ downloads ” license in the extension manifest to use this API. An error broke the connection with the file master of ceremonies.
Reading: Chrome.downloads – Flickroom
The download is presently receiving data from the server. The size of the render picture. The picture will be square with dimensions size * size pixels. The default and largest size for the icon is 32×32 pixels. The merely support sizes are 16 and 32. It is an error to specify any other size. The DownloadItem ‘s new target DownloadItem.filename, as a way relative to the exploiter ‘s default Downloads directory, possibly containing subdirectories. Absolute paths, empty paths, and paths containing back-references “ .. ” will be ignored. filename is ignored if there are any onDeterminingFilename listeners registered by any extensions. The military action to take if filename already exists. The drug user will be prompted with a file picker dialogue. The existing file will be overwritten with the raw file. To avoid duplicate, the filename is changed to include a antagonistic before the filename extension. Limits results to DownloadItem whose url matches the given regular construction. The absolute URL that this download initiated from, before any redirects. Limits results to DownloadItem whose totalBytes is less than the given integer. Limits results to DownloadItem whose totalBytes is greater than the given integer. Number of bytes in the unharmed file, without considering file compaction, or -1 if strange. Indicates whether the download is progressing, interrupted, or complete. Limits results to DownloadItem that started before the given mississippi since the epoch. Limits results to DownloadItem that started after the given megabyte since the epoch. The time when the download began in ISO 8601 format. This array of search terms limits results to DownloadItem whose filename or url or finalUrl contain all of the search terms that do not begin with a daunt ‘- ‘ and none of the search terms that do begin with a hyphen. true if the download has stopped reading data from the horde, but kept the connection open. put elements of this array to DownloadItem properties in order to sort research results. For example, setting orderBy= [ ‘startTime ‘ ] sorts the DownloadItem by their start meter in ascending holy order. To specify descending order, prefix with a hyphenate : ‘-startTime ‘. The maximum count of matching DownloadItem returned. Defaults to 1000. Set to 0 in order to return all meet DownloadItem. See search for how to page through results. The id of the DownloadItem to query. Limits results to DownloadItem whose finalUrl matches the given even saying. The absolute URL that this download is being made from, after all redirects. Limits results to DownloadItem whose filename matches the given regular expression. Number of bytes in the whole file post-decompression, or -1 if strange. Limits results to DownloadItem that ended before the given meter since the era. Limits results to DownloadItem that ended after the given megabyte since the epoch. The time when the download ended in ISO 8601 format. indication of whether this download is thought to be dependable or known to be fishy. Number of bytes received so far from the host, without considering file compression. Use a file-chooser to allow the user to select a filename regardless of whether filename is set or already exists. The HTTP method to use if the URL uses the HTTP [ S ] protocol. Extra HTTP headers to send with the request if the URL uses the HTTP [ s ] protocol. Each header is represented as a dictionary containing the keys name and either prize or binaryValue, restricted to those allowed by XMLHttpRequest. A file path proportional to the Downloads directory to contain the download file, possibly containing subdirectories. Absolute paths, vacate paths, and paths containing back-references “ .. ” will cause an error. onDeterminingFilename allows suggesting a filename after the file ‘s MIME type and a probationary filename have been determined. The carry through to take if filename already exists. The absolute URL that this download initiated from, before any redirects. Number of bytes in the unharmed file, without considering file compression, or -1 if stranger. Indicates whether the download is progressing, interrupted, or complete. The time when the download began in ISO 8601 format. May be passed directly to the Date builder : chrome.downloads.search ( { }, function ( items ) { items.forEach ( function ( detail ) { console.log ( raw Date ( item.startTime ) ) } ) } ) true if the download has stopped reading data from the host, but kept the association exposed. false if this download is recorded in the history, truthful if it is not recorded. An identifier that is persistent across browser sessions. The absolute URL that this download is being made from, after all redirects. Number of bytes in the whole file post-decompression, or -1 if strange. Whether the downloaded charge distillery exists. This information may be out of date because Chrome does not automatically watch for file removal. Call search ( ) in order to trigger the check for charge being. When the universe check completes, if the charge has been deleted, then an onChanged event will fire. note that search ( ) does not wait for the universe match to finish before render, so results from search ( ) may not accurately reflect the file system. besides, search ( ) may be called angstrom frequently as necessity, but will not check for charge being any more frequently than once every 10 seconds. Estimated time when the download will complete in ISO 8601 format. May be passed directly to the Date builder : chrome.downloads.search ( { }, serve ( items ) { items.forEach ( function ( item ) { if ( item.estimatedEndTime ) console.log ( new Date ( item.estimatedEndTime ) ) } ) } ) Why the download was interrupted. several kinds of HTTP errors may be grouped under one of the errors beginning with SERVER_. Errors relating to the network get down with NETWORK_, errors relating to the procedure of writing the file to the file system begin with FILE_, and interruptions initiated by the user begin with USER_. The time when the download ended in ISO 8601 format. May be passed directly to the Date builder : chrome.downloads.search ( { }, routine ( items ) { items.forEach ( function ( detail ) { if ( item.endTime ) console.log ( newfangled Date ( item.endTime ) ) } ) } ) indication of whether this download is thought to be safe or known to be leery. true if the download is in progress and paused, or else if it is interrupted and can be resumed starting from where it was interrupted. Number of bytes received then far from the server, without considering charge compaction. The localized name of the annex that initiated this download if this download was initiated by an extension. May change if the extension changes its name or if the drug user changes their venue. The identifier for the extension that initiated this download if this download was initiated by an extension. Does not change once it is set. The change in url, if any. The transfer in totalBytes, if any. The change in state, if any. The transfer in startTime, if any. The change in pause, if any. The change in mime, if any. The id of the DownloadItem that changed. The exchange in finalUrl, if any. The change in filename, if any. The change in fileSize, if any. The change in exists, if any. The change in error, if any. The change in endTime, if any. The change in risk, if any. The deepen in canResume, if any. The download presents no know risk to the drug user ‘s computer. The download is potentially undesirable or insecure. E.g. it could make changes to browser or calculator settings. The download came from a server known to distribute malicious binaries and is probably dangerous. The download ‘s URL is not normally downloaded and could be dangerous. The download file is known to be malicious. The download ‘s URL is known to be malicious .
Contents
acceptDanger
chrome.downloads.acceptDanger(
downloadId:
number
,
callback?:
function
,
)
Promise
Prompt the exploiter to accept a dangerous download. Can only be called from a visible context ( pill, window, or page/browser action popup ). Does not automatically accept dangerous downloads. If the download is accepted, then an onChanged
event will fire, differently nothing will happen. When all the datum is fetched into a temp file and either the download is not dangerous or the danger has been accepted, then the temp file is renamed to the target filename, the state
changes to ‘complete ‘, and onChanged
fires .
Parameters
- downloadId number The identifier for the
DownloadItem
. - recall function optional The
callback
parameter looks like :() => void
Returns
- Promise
Pending
This only returns a
Promise
when thecallback
parameter is not specified, and with MV3+. The type inside thePromise
is the lapp as the 1st argumentation tocallback
.
cancel
chrome.downloads.cancel(
downloadId:
number
,
callback?:
function
,
)
Promise
Cancel a download. When callback
is run, the download is cancelled, completed, interrupted or does n’t exist anymore .
Parameters
- downloadId number The id of the download to cancel .
- recall function optional The
callback
parameter looks like :() => void
Returns
- Promise
Pending
This entirely returns a
Promise
when thecallback
parameter is not specified, and with MV3+. The type inside thePromise
is the same as the 1st argument tocallback
.
download
chrome.downloads.download(
options: DownloadOptions
callback?: serve,
)
Promise
Download a URL. If the URL uses the HTTP [ S ] protocol, then the request will include all cookies presently set for its hostname. If both filename
and saveAs
are specified, then the Save As dialogue will be displayed, pre-populated with the specified filename
. If the download started successfully, callback
will be called with the modern DownloadItem
‘s downloadId
. If there was an mistake starting the download, then callback
will be called with downloadId=undefined
and runtime.lastError
will contain a descriptive string. The error strings are not guaranteed to remain backwards compatible between releases. Extensions must not parse it .
Parameters
- options DownloadOptions What to download and how .
- recall function optional The
callback
parameter looks like :(downloadId: number) => void
- downloadId
Read more: How to Embed a Google Form: Flickroom
count
- downloadId
Returns
- Promise
Pending
This merely returns a
Promise
when thecallback
parameter is not specified, and with MV3+. The type inside thePromise
is the same as the 1st argument tocallback
.
erase
chrome.downloads.erase(
query: DownloadQuery
callback?: function,
)
Promise
Erase matching DownloadItem
from history without deleting the downloaded file. An onErased
event will fire for each DownloadItem
that matches query
, then callback
will be called .
Parameters
- question DownloadQuery
- recall serve optional The
callback
argument looks like :(erasedIds: number[]) => void
- erasedIds number
Returns
- Promise <number[]></number[]>
Pending
This entirely returns a
Promise
when thecallback
argument is not specified, and with MV3+. The type inside thePromise
is the same as the 1st argumentation tocallback
.
getFileIcon
chrome.downloads.getFileIcon(
downloadId: numeral,
options?: GetFileIconOptions
callback?: function,
)
Promise
Retrieve an picture for the specified download. For new downloads, file icons are available after the onCreated
consequence has been received. The trope returned by this function while a download is in build up may be different from the trope returned after the download is complete. Icon retrieval is done by querying the underlying operate system or toolkit depending on the platform. The picture that is returned will therefore count on a number of factors including state of the download, platform, registered file types and ocular theme. If a file icon can not be determined, runtime.lastError
will contain an error message .
Parameters
- downloadId total The identifier for the download .
- options GetFileIconOptions optional
- recall function optional The
callback
argument looks like :(iconURL?: string) => void
- iconURL string optional
Returns
- Promise
Pending
This merely returns a
Promise
when thecallback
parameter is not specified, and with MV3+. The type inside thePromise
is the same as the 1st argumentation tocallback
.
open
chrome.downloads.open(
downloadId:
number
,
) Open the download charge now if the DownloadItem
is arrant ; differently returns an error through runtime.lastError
. Requires the "downloads.open"
permission in accession to the "downloads"
permission. An onChanged
event will fire when the item is opened for the first base clock .
Parameters
- downloadId count The identifier for the download file .
pause
chrome.downloads.pause(
downloadId:
number
,
callback?:
function
,
)
Promise
Pause the download. If the request was successful the download is in a hesitate express. Otherwise runtime.lastError
contains an error message. The request will fail if the download is not active .
Parameters
- downloadId number The id of the download to pause .
- recall serve optional The
callback
parameter looks like :() => void
Returns
- Promise
Pending
This only returns a
Promise
when thecallback
parameter is not specified, and with MV3+. The type inside thePromise
is the like as the 1st argument tocallback
.
removeFile
chrome.downloads.removeFile(
downloadId:
number
,
callback?:
function
,
)
Promise
Remove the downloaded file if it exists and the DownloadItem
is accomplished ; otherwise return an error through runtime.lastError
.
Parameters
- downloadId phone number
- recall function optional The
callback
argument looks like :() => void
Returns
- Promise
Pending
This entirely returns a
Promise
when thecallback
argument is not specified, and with MV3+. The type inside thePromise
is the same as the 1st argument tocallback
.
resume
chrome.downloads.resume(
downloadId:
number
,
callback?:
function
,
)
Promise
Resume a hesitate download. If the request was successful the download is in build up and unpaused. Otherwise runtime.lastError
contains an error message. The request will fail if the download is not active .
Parameters
- downloadId number The id of the download to resume .
- recall affair optional The
callback
parameter looks like :() => void
Returns
- Promise
Pending
This only returns a
Promise
when thecallback
parameter is not specified, and with MV3+. The type inside thePromise
is the same as the 1st argument tocallback
.
search
chrome.downloads.search(
query: DownloadQuery
callback?: function,
)
Promise
Find DownloadItem
. Set query
to the empty object to get all DownloadItem
. To get a specific DownloadItem
, set lone the id
field. To page through a big number of items, set orderBy: ['-startTime']
, set limit
to the number of items per page, and set startedAfter
to the startTime
of the last token from the last page .
Parameters
- question DownloadQuery
- recall function optional The
callback
parameter looks like :(results: DownloadItem[]) => void
- results DownloadItem
Returns
- Promise < DownloadItem >
Pending
This lone returns a
Promise
when thecallback
parameter is not specified, and with MV3+. The type inside thePromise
is the same as the 1st argument tocallback
.
setShelfEnabled
chrome.downloads.setShelfEnabled(
enabled:
boolean
,
) enable or disable the grey ledge at the bottom of every window associated with the current browser profile. The ledge will be disabled ampere long as at least one extension has disabled it. Enabling the ledge while at least one early extension has disabled it will return an error through runtime.lastError
. Requires the "downloads.shelf"
license in addition to the "downloads"
permission .
Parameters
- enabled boolean
show
chrome.downloads.show(
downloadId:
number
,
) Show the download file in its booklet in a file director .
Parameters
- downloadId number
Read more: How to Change Your IP Address
The identifier for the download file .
showDefaultFolder
chrome.downloads.showDefaultFolder()
Show the default Downloads booklet in a file director .