I am developing a small Chrome extension and needed to download a file off web. Here's how the script behaves:
service_worker JS file (either on a command event or with no conditionals at all)saveAs dialog never opens even if set to true)DownloadItem object for the returned ID, its status is found to be interrupted and its reason to be USER_CANCELEDchrome.runtime.lastError is undefined as well.downloads in the permissions<all_urls> in host permissions (for debugging)Ask where to save each file before downloading setting is turned off and...filename/saveAs isn't set in passed DownloadOptionsBut shouldn't the download work nonetheless?
chrome.commands.onCommand.addListener((command) => {
const url = "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"; //random image
chrome.downloads.download({url, saveAs: true}, (id) => {
console.log(chrome.downloads.search({id}, (result) => {
console.log(result)
console.log(chrome.runtime.lastError)
}))
})
})
Any idea what's going on? Any help would be highly appreciated!