chrome扩展名,用于访问下载文件的内容 [英] chrome extension to access content of downloaded files

查看:149
本文介绍了chrome扩展名,用于访问下载文件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Chrome扩展程序,并且希望拥有该扩展程序:

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

  1. 单击链接以开始文件下载
  2. 下载完成后,打开并阅读下载文件的内容
  3. 对JavaScript中文件的内容进行处理

我看到 chrome.downloads API允许我启动下载并打开文件,但是我可以读取文件的内容(而无需编写本机代码)吗?

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)?

推荐答案

我正在在这里复制我给出的答案

I'm copying the answer I gave here.

您只需要在清单文件中为file://*添加权限,并在系统中拥有文件路径后即可(使用

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}.

这篇关于chrome扩展名,用于访问下载文件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆