I have long wanted to make a chrome extension for myself in order to package upload images. But every time I was upset, because the only applicable option is NPAPI, which both chrome and firefox seem to no longer want to support.
I suggest for those who still want to implement the "save-file-on-disk" functionality in order to view this https://stackoverflow.com/a/167958/ , the comment below this post will help me a lot.
Now that chrome is 31+, the chrome.downloads API has become stable. We can use it to programmatically download a file. If the user has not set the ask me before every download advance option in chrome, we can save the file without asking for user confirmation!
Here is what I use (on an extra background page):
// remember to add "permissions": ["downloads"] to manifest.json // this snippet is inside a onMessage() listener function var imgurl = "https://www.google.com.hk/images/srpr/logo11w.png"; chrome.downloads.download({url:imgurl},function(downloadId){ console.log("download begin, the downId is:" + downloadId); });
Although it is a pity that chrome still does not provide Event when the download is completed. chrome.downloads.download callback function is called when the begin load is successful (not completed)
The official documentation for chrome.downloads here .
This is not my original idea of ββa solution, but I wrote here, hoping this could help someone.
Allan Ruin Mar 01 '14 at 10:50 2014-03-01 10:50
source share