aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/window/requestfilesystem/index.html
blob: 17561dfda086e68d0edfc286cd0dd2cae9f41b81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
title: Window.requestFileSystem()
slug: Web/API/Window/requestFileSystem
translation_of: Web/API/Window/requestFileSystem
---
<p>{{APIRef("File System API")}}</p>

<p>这个非标准 {{domxref("Window")}} <strong><code>requestFileSystem()</code></strong> 方法是谷歌浏览器内核用来让web站点或app获得通过沙箱访问文件系统 . 它返回 {{domxref("FileSystem")}} 然后就可以和 <a href="/en-US/docs/Web/API/File_and_Directory_Entries_API">file system APIs</a> 一起使用了</p>

<div class="warning">
<p>甚至相比较如File和Directory Entries API, <code>requestFileSystem()</code> 更不规范; 只有Chrome支持它, 所有其它浏览器已经决定不支持它了. 它甚至已经从规范建议单中移除了. 因此<em>不要使用这个方法</em></p>
</div>

<h2 id="语法">语法</h2>

<div class="note">
<p><code>在所有支持它的浏览器中这个方法都有webkit前缀</code> (实际上也仅有谷歌浏览器支持).</p>
</div>

<pre class="syntaxbox">window.requestFileSystem(<em>type</em>, <em>size</em>, <em>successCallback</em>[, <em>errorCallback</em>]);</pre>

<h3 id="参数">参数</h3>

<dl>
 <dt><code>type</code></dt>
 <dd>要请求的存储类型. 指定<code>Window.TEMPORARY</code> 浏览器自行决定要不要删除文件, 例如低内存, 或者<code>Window.PERSISTENT</code> 如果你需要文件保持在这个地方必须用户或站点或app明确许可. 持久存储要求用户授予站点配额</dd>
 <dt><code>size</code></dt>
 <dd>你希望你的app被允许的使用空间大小.</dd>
 <dt><code>successCallback</code></dt>
 <dd>
 <p>成功获取文件系统时调用的函数。<span style="font-size: 1rem; letter-spacing: -0.00278rem;">回调接收单个参数: 一个 {{domxref("FileSystem")}} 表示应用程序有权使用的文件系统的对象.</span></p>
 </dd>
 <dt><code>errorCallback</code> {{optional_inline}}</dt>
 <dd>一个可选参数,指定在试图获取文件系统时发生错误或用户拒绝创建或访问文件系统的权限时调用的函数。回调接收单个参数作为输入:一个{{domxref("FileError")}}用来描述错误的对象</dd>
</dl>

<h3 id="返回值">返回值</h3>

<p><font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">无返回值</span></font></p>

<h2 id="示例">示例</h2>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">规范</th>
   <th scope="col">状态</th>
   <th scope="col">注释</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('File System API')}}</td>
   <td>{{Spec2('File System API')}}</td>
   <td>Draft of proposed API</td>
  </tr>
 </tbody>
</table>

<p>这个API没有W3C或者WHATWG的官方规范.</p>

<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>



<p>{{Compat("api.Window.requestFileSystem")}}</p>

<h2 id="相关知识">相关知识</h2>

<ul>
 <li><a href="/en-US/docs/Web/API/File_and_Directory_Entries_API/Firefox_support">File and Directory Entries API support in Firefox</a></li>
</ul>