下载从数据 uri 解码的图像 - chrome 扩展

download image decoded from data uri - chrome extension

我有一个数据 uri 图像,在将其解码并显示为 <img> 标签后,我想让用户能够下载它。如何在 chrome 扩展中实现此目的?我需要将哪种 url 传递给 chrome.downloads.download api 方法?

此功能应该可以使用,而且我认为只要您能看到图像,它就应该可以与现有的 url

一起使用
 function downloadImage(url, outputFileName){
      var a = document.createElement('a');
      a.href = url;
      a.download = outputFileName;
      document.body.appendChild(a);
      a.click();
      document.body.removeChild(a); 
    }