Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and code samples are licensed under the BSD License.
©2011 Google
For information on how to use experimental APIs, see the chrome.experimental.* APIs page.
The downloads API allows you to programmatically initiate downloads. In the future, you will also be able to monitor and manipulate downloads.
The downloads API is currently experimental, so you must declare the "experimental" permission to use it. Also, you must specify the hostname of any URLs to be downloaded. For example:
{ "name": "Download Selected Links", "description": "Select links on a page and download them.", "version": "0.1", "permissions": [ "experimental", "http://*/*", "https://*/*" ] }
If the URL’s hostname is not specified in the permissions, then the chrome.extensions.lastError object will indicate that the extension does not have permission to access that hostname. downloads.ERROR_* are some of the errors that may be returned.
You can find simple examples of using the downloads module in the examples/api/downloads directory. For other examples and for help in viewing the source code, see Samples.
"uncommon"
)
Download a URL. If the URL uses the HTTP[S] protocol, then the request will include all cookies currently set for its hostname. If the download started successfully, callback
will be called with the new DownloadItem’s downloadId
. If there was an error starting the download, then callback
will be called with downloadId=undefined
and chrome.extension.lastError
will be set. If both filename
and saveAs
are specified, then the Save As dialog will be displayed, pre-populated with the specified filename
.
If you specify the callback parameter, it should specify a function that looks like this:
function(integer downloadId) {...};
name
and either value
or binaryValue
.