downloads.DownloadQuery
The DownloadQuery type of the downloads API defines a set of parameters that can be used to search the downloads manager for a specific set of downloads.
The DownloadQuery type of the downloads API defines a set of parameters that can be used to search the downloads manager for a specific set of downloads.
This type is used for example in downloads.search() and downloads.erase(), as a query object to filter the set of DownloadItems to return or erase.
Type
Values of this type are objects. They contain the following properties:
cookieStoreId- : The cookie store ID of the contextual identity in which the download took place. See Work with contextual identities for more information.
query- : An
arrayofstrings. Include only DownloadItems whosefilenameorurlcontains all of the given strings. You can also include terms beginning with a dash (-) — these terms must not be contained in the item'sfilenameorurlfor it to be included. startedBefore- : A DownloadTime. Include only DownloadItems that started before the given time.
startedAfter- : A DownloadTime. Include only DownloadItems that started after the given time.
endedBefore- : A DownloadTime. Include only DownloadItems that ended before the given time.
endedAfter- : A DownloadTime. Include only DownloadItems that ended after the given time.
totalBytesGreater- : A
numberrepresenting a number of bytes. Include only DownloadItems whosetotalBytesis greater than the given number. totalBytesLess- : A
numberrepresenting a number of bytes. Include only DownloadItems whosetotalBytesis less than the given number. filenameRegex- : A
stringrepresenting a regular expression. Include only DownloadItems whosefilenamevalue matches the given regular expression. urlRegex- : A
stringrepresenting a regular expression. Include only DownloadItems whoseurlvalue matches the given regular expression. limit- : An
integerrepresenting a number of results. Include only the specified number of DownloadItems. orderBy- : An
arrayofstrings representing DownloadItem properties the search results should be sorted by. For example, includingstartTimethentotalBytesin the array would sort the DownloadItems by their start time, then total bytes — in ascending order. To specify sorting by a property in descending order, prefix it with a hyphen, for example-startTime. id- : An
integerrepresenting the ID of the downloads.DownloadItem you want to query. url- : A
stringrepresenting the absolute URL that the download was initiated from, before any redirects. filename- : A string representing the absolute local path of the download file you want to query.
danger- : A string representing a downloads.DangerType — include only DownloadItems with this
dangervalue. mime- : A
stringrepresenting a MIME type. Include only DownloadItems with thismimevalue. startTime- : A
stringrepresenting an ISO 8601 format time. Include only DownloadItems with thisstartTimevalue. endTime- : A
stringrepresenting an ISO 8601 format time. Include only DownloadItems with thisendTimevalue. state- : A
stringrepresenting a download downloads.State (in_progress,interrupted, orcomplete). Include only DownloadItems with thisstatevalue. paused- : A
booleanthat indicates whether a download is paused — i.e., has stopped reading data from the host, but kept the connection open (true), or not (false). Include only DownloadItems with thispausedvalue. error- : A string representing a downloads.InterruptReason — a reason why a download was interrupted. Include only DownloadItems with this
errorvalue. bytesReceived- : A
numberrepresenting the number of bytes received so far from the host, without considering file compression. Include only DownloadItems with thisbytesReceivedvalue. totalBytes- : A
numberrepresenting the total number of bytes in the downloaded file, without considering file compression. Include only DownloadItems with thistotalBytesvalue. fileSize- :
number. Number of bytes in the whole file post-decompression, or -1 if unknown. Anumberrepresenting the total number of bytes in the file after decompression. Include only DownloadItems with thisfileSizevalue. exists- : A
booleanindicating whether a downloaded file still exists (true) or not (false). Include only DownloadItems with thisexistsvalue.
Browser compatibility
[!NOTE] This API is based on Chromium's
chrome.downloadsAPI.