在Chrome中下载后访问文件数据...? [英] Accessing file data after download in Chrome...?
问题描述
我正在编写一个扩展程序,它可以在下载完成后理想地读取文件(通过正常的下载过程)。那可能吗?我可以通过chrome.downloads操作获取文件名,但我无法找到读取实际字节的方法。我不需要写或移动它们,只需阅读。
I'm writing an extension that would ideally read files after they are downloaded (through the normal download process). Is that possible? I can get the filename through chrome.downloads operations, but I can't find ways of reading the actual bytes. I don't need to write or move them, just read.
推荐答案
我挣扎于完全相同的问题,终于找到了简单的解决方法来从Chrome扩展中读取下载文件的内容。
I struggled with the exact same problem and finally found an easy workaround to read the content of downloaded files from a Chrome extension.
您只需要添加 file的权限:// *
在你的清单文件中,并且一旦你在系统中有你的文件路径( chrome.downloads.search
,在文件名
属性中设置一个GET XMLHttpRequest file:// {filepath}
。
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屋!