The download()
function of the downloads
API downloads a file, given its URL and other optional preferences.
If the URL uses the HTTP or HTTPS protocol, the request includes all the relevant cookies, that is, those cookies set for the URL's hostname, secure flag, path, and so on. The default cookies, the cookies from the normal browsing session, are used unless:
- the
incognito
option is used, then the private browsing cookies are used. - the
cookieStoreId
option is used, then the cookies from the specified store are used.
If both filename
and saveAs
are specified, the Save As dialog is displayed, populated with the filename
.
This is an asynchronous function that returns a Promise
.