fri*_*jet 7 filesystems google-chrome google-chrome-os google-chrome-extension
我想为测试目的创建Chrome扩展程序.并且该扩展应该能够访问本地硬盘驱动器上的目录和文件.
我file:///*在我的manifest.json文件中请求了权限.然后我确保Allow access to file URLs选中了复选框.然后我为一个文件制作了一个XHR:
var xhr = new XMLHttpRequest();
xhr.open("GET", 'file://c:/dir/file.name', true);
xhr.onload = function(e) {
console.log('response: ', xhr.response);
}
xhr.send();
Run Code Online (Sandbox Code Playgroud)
...和整个目录的XHR:
var xhr = new XMLHttpRequest();
xhr.open("GET", 'file://c:/dir/', true);
xhr.onload = function(e) {
console.log('response: ', xhr.response);
}
xhr.send();
Run Code Online (Sandbox Code Playgroud)
...并且对于整个文件系统:
var xhr = new XMLHttpRequest();
xhr.open("GET", 'file:///', true);
xhr.onload = function(e) {
console.log('response: ', xhr.response);
}
xhr.send();
Run Code Online (Sandbox Code Playgroud)
.
<html>
<head>
<script>
Run Code Online (Sandbox Code Playgroud)
[...]
</script>
<style>
Run Code Online (Sandbox Code Playgroud)
[...]
</style>
<title id="title"></title>
</head>
<body>
<div id="listingParsingErrorBox" i18n-values=".innerHTML:listingParsingErrorBoxText"></div>
<span id="parentDirText" style="display:none" i18n-content="parentDirText"></span>
<h1 id="header" i18n-content="header"></h1>
<table id="table">
<tr class="header">
<td i18n-content="headerName"></td>
<td class="detailsColumn" i18n-content="headerSize"></td>
<td class="detailsColumn" i18n-content="headerDateModified"></td>
</tr>
</table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
[...]
<script>start("C:\\dir\\");</script>
<script>addRow("..","..",1,"0 B","11/11/11 11:11:11 AM");</script>
<script>addRow("file.name","file.name",0,"4.9 kB","11/11/11 11:11:11 PM");</script>
Run Code Online (Sandbox Code Playgroud)
我能读懂简单的文件.但是我的扩展如何获得一个很好的机器可读的目录或整个文件系统的概述?谢谢.
编辑:我知道FileSystem API旨在访问沙盒filesystem://,但也许Chrome允许扩展也访问file://.我找不到任何有关file://Chrome扩展程序访问权限的文档,所以我只能猜测.
| 归档时间: |
|
| 查看次数: |
5721 次 |
| 最近记录: |