Nw.js: Is there any possibility to listenTo file download in node webkit?

Created on 19 Jan 2017  ·  11Comments  ·  Source: nwjs/nw.js

like this
image

needinfo

Most helpful comment

You can try with chrome.downloads API. See https://developer.chrome.com/extensions/downloads. If it doesn't work, please feedback here.

All 11 comments

Need the download bar like chrome

You can try with chrome.downloads API. See https://developer.chrome.com/extensions/downloads. If it doesn't work, please feedback here.

ok,I will try now

image
I don't know where is the "permission" should be added.package.json?
like this
image
@ghostoy

There is no need to set permission in package.json. If chrome.downloads doesn't work without the permission, we will seek to fix it.

chrome.downloads.download is ok to run.But chrome.downloads.onChanged.addListener will cause the result that file download failed.
test code
const chrome = window.chrome; if(chrome && chrome.downloads) { chrome.downloads.onChanged.addListener(({id, state={}, error}) => { console.log(id, state); if(state.current === chrome.downloads.State.COMPLETE) { chrome.downloads.show(id); } }) }

chrome.downloads..download was runned after chrome.downloads.onChanged.addListener

Oh sorry.I find it ok when run the code again.
But I don't catch the method or any properties to show download bar in chrome extension api

Yes, there is no download UI for it. You can implement your own.

BTW, you can use Node.js APIs to download files as well. But chrome.downloads can intercept the downloads initiated from web page.

I find another way to solve my problem.I can use chrome.downloads.onChanged.addListener to listen to my download percentange and show it on a message modal.Thank you. @ghostoy

怎么解决?

Was this page helpful?
0 / 5 - 0 ratings