chrome extension to access content of downloaded files

醉酒当歌 提交于 2020-01-01 11:59:26

问题


I'm working on a Chrome extension and I'd like to have the extension:

  1. Click on a link to initiate a file download
  2. Once the download is complete, open and read the contents of the downloaded file
  3. Do something with the contents of the file in JavaScript

I see that the chrome.downloads API allows me to initiate the download and open the file, but is it possible for me to read the contents of the file (without writing native code)?


回答1:


I'm copying the answer I gave here.

You just need to add a permission to file://*in your manifest file and once you have your file's path in the system (with chrome.downloads.search in the filename property), make a GET XMLHttpRequest to the url file://{filepath}.



来源:https://stackoverflow.com/questions/41767585/chrome-extension-to-access-content-of-downloaded-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!