downloads.DownloadQuery
TheDownloadQuery type of thedownloads 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 indownloads.search() anddownloads.erase(), as a query object to filter the set ofDownloadItems to return or erase.
In this article
Type
Values of this type are objects. They contain the following properties:
cookieStoreIdOptionalThe cookie store ID of thecontextual identity in which the download took place. SeeWork with contextual identities for more information.
queryOptionalAn
arrayofstrings. Include onlyDownloadItemswhosefilenameorurlcontains all of the given strings. You can also include terms beginning with a dash (-) — these termsmust not be contained in the item'sfilenameorurlfor it to be included.startedBeforeOptionalA
DownloadTime. Include onlyDownloadItemsthat started before the given time.startedAfterOptionalA
DownloadTime. Include onlyDownloadItemsthat started after the given time.endedBeforeOptionalA
DownloadTime. Include onlyDownloadItemsthat ended before the given time.endedAfterOptionalA
DownloadTime. Include onlyDownloadItemsthat ended after the given time.totalBytesGreaterOptionalA
numberrepresenting a number of bytes. Include onlyDownloadItemswhosetotalBytesis greater than the given number.totalBytesLessOptionalA
numberrepresenting a number of bytes. Include onlyDownloadItemswhosetotalBytesis less than the given number.filenameRegexOptionalA
stringrepresenting a regular expression. Include onlyDownloadItemswhosefilenamevalue matches the given regular expression.urlRegexOptionalA
stringrepresenting a regular expression. Include onlyDownloadItemswhoseurlvalue matches the given regular expression.limitOptionalAn
integerrepresenting a number of results. Include only the specified number ofDownloadItems.orderByOptionalAn
arrayofstrings representingDownloadItemproperties the search results should be sorted by. For example, includingstartTimethentotalBytesin the array would sort theDownloadItemsby 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.idOptionalAn
integerrepresenting the ID of thedownloads.DownloadItemyou want to query.urlOptionalA
stringrepresenting the absolute URL that the download was initiated from, before any redirects.filenameOptionalA string representing the absolute local path of the download file you want to query.
dangerOptionalA string representing a
downloads.DangerType— include onlyDownloadItemswith thisdangervalue.mimeOptionalA
stringrepresenting a MIME type. Include onlyDownloadItemswith thismimevalue.startTimeOptionalA
stringrepresenting anISO 8601 format time. Include onlyDownloadItemswith thisstartTimevalue.endTimeOptionalA
stringrepresenting anISO 8601 format time. Include only will limited toDownloadItemswith thisendTimevalue.stateOptionalA
stringrepresenting a downloaddownloads.State(in_progress,interrupted, orcomplete). Include onlyDownloadItemswith thisstatevalue.pausedOptionalA
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 onlyDownloadItemswith thispausedvalue.errorOptionalA string representing a
downloads.InterruptReason— a reason why a download was interrupted. Include onlyDownloadItemswith thiserrorvalue.bytesReceivedOptionalA
numberrepresenting the number of bytes received so far from the host, without considering file compression. Include onlyDownloadItemswith thisbytesReceivedvalue.totalBytesOptionalA
numberrepresenting the total number of bytes in the downloaded file, without considering file compression. Include onlyDownloadItemswith thistotalBytesvalue.fileSizeOptionalnumber. 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 onlyDownloadItemswith thisfileSizevalue.existsOptionalA
booleanindicating whether a downloaded file still exists (true) or not (false). Include onlyDownloadItemswith thisexistsvalue.
Browser compatibility
Note:This API is based on Chromium'schrome.downloads API.