aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/blobbuilder/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/blobbuilder/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/blobbuilder/index.html')
-rw-r--r--files/zh-cn/web/api/blobbuilder/index.html172
1 files changed, 172 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/blobbuilder/index.html b/files/zh-cn/web/api/blobbuilder/index.html
new file mode 100644
index 0000000000..03248ac1e5
--- /dev/null
+++ b/files/zh-cn/web/api/blobbuilder/index.html
@@ -0,0 +1,172 @@
+---
+title: BlobBuilder
+slug: Web/API/BlobBuilder
+translation_of: Web/API/BlobBuilder
+---
+<p>{{ deprecated_header() }}</p>
+<p>{{ SeeCompatTable() }}</p>
+<p>The <code>BlobBuilder</code> interface provides an easy way to construct {{ domxref("Blob") }} objects. Just create a <code>BlobBuilder</code> and append chunks of data to it by calling the {{ manch("append") }} method. When you're done building your blob, call {{ manch("getBlob") }} to retrieve a {{ domxref("Blob") }} containing the data you sent into the blob builder.</p>
+<div class="note">
+ <strong>注:</strong><code>BlobBuilder</code>接口已经废弃,请使用新版草案中引入的 {{domxref('Blob') }}构造函数.</div>
+<h2 id="Method_overview" name="Method_overview">方法概述</h2>
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <td><code>void <a href="/zh-CN/DOM/BlobBuilder#append()" title="zh-CN/DOM/BlobBuilder#append()">append</a>(in ArrayBuffer data);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/zh-CN/DOM/BlobBuilder#append()" title="zh-CN/DOM/BlobBuilder#append()">append</a>(in Blob data);</code></td>
+ </tr>
+ <tr>
+ <td><code>void <a href="/zh-CN/DOM/BlobBuilder#append()" title="zh-CN/DOM/BlobBuilder#append()">append</a>(in String data, [optional] in String endings);</code></td>
+ </tr>
+ <tr>
+ <td><code>Blob <a href="/zh-CN/DOM/BlobBuilder#getBlob()" title="zh-CN/DOM/BlobBuilder#getBlob()">getBlob</a>([optional] in DOMString contentType);</code></td>
+ </tr>
+ <tr>
+ <td><code>File <a href="/zh-CN/DOM/BlobBuilder#getFile()" title="zh-CN/DOM/BlobBuilder#getFile()">getFile</a>(in DOMString name, [optional] in DOMString contentType);</code></td>
+ </tr>
+ </tbody>
+</table>
+<h2 id="方法">方法</h2>
+<h3 id="append()">append()</h3>
+<p>Appends the contents of the specified JavaScript object to the {{ domxref("Blob") }} being built. If the value you specify isn't a {{ domxref("Blob") }}, <a href="/zh-CN/JavaScript_typed_arrays/ArrayBuffer" title="zh-CN/JavaScript typed arrays/Arraybuffer"><code>ArrayBuffer</code></a>, or <a href="/zh-CN/JavaScript/Reference/Global_Objects/String" title="zh-CN/JavaScript/Reference/Global Objects/String"><code>String</code></a>, the value is coerced to a string before being appended to the blob.</p>
+<pre>void append(
+ in ArrayBuffer data
+);
+
+void append(
+ in Blob data
+);
+
+
+void append(
+ in String data,
+ [optional] in String endings
+);
+</pre>
+<h6 id="参数">参数</h6>
+<dl>
+ <dt>
+ <code>data</code></dt>
+ <dd>
+ The data to append to the {{ domxref("Blob") }} being constructed.</dd>
+ <dt>
+ <code>endings</code></dt>
+ <dd>
+ Specifies how strings containing <code>\n</code> are to be written out. This can be <code>"transparent"</code> (endings unchanged) or <code>"native"</code> (endings changed to match host OS filesystem convention). The default value is <code>"transparent"</code>.</dd>
+</dl>
+<h3 id="getBlob()">getBlob()</h3>
+<p>Returns the {{ domxref("Blob") }} object that has been constructed using the data passed through calls to {{ manch("append") }}.</p>
+<pre class="eval">Blob getBlob(
+ in DOMString contentType {{ optional_inline() }}
+);
+</pre>
+<h6 id="参数_2">参数</h6>
+<dl>
+ <dt>
+ contentType {{ optional_inline() }}</dt>
+ <dd>
+ The MIME type of the data to be returned in the {{ domxref("Blob") }}. This will be the value of the <code>Blob</code> object's type property.</dd>
+</dl>
+<h6 id="返回值">返回值</h6>
+<p>A {{ domxref("Blob") }} object containing all of the data passed to any calls to {{ manch("append") }} made since the <code>BlobBuilder</code> was created. This also resets the <code>BlobBuilder</code> so that the next call to {{ manch("append") }} is starting a new, empty blob.</p>
+<h3 id="getFile()_non-standard_inline()">getFile() {{ non-standard_inline() }}</h3>
+<p>返回一个{{ domxref("File") }}对象.</p>
+<pre class="eval">File getFile(
+ in DOMString name,
+ [optional] in DOMString contentType
+);
+</pre>
+<h6 id="参数_3">参数</h6>
+<dl>
+ <dt>
+ name</dt>
+ <dd>
+ 文件名.</dd>
+ <dt>
+ contentType {{ optional_inline() }}</dt>
+ <dd>
+ 设置返回的{{ domxref("File") }}对象中的数据的MIME类型.这个值将会成为返回<code>的File</code>对象的type属性的值.</dd>
+</dl>
+<h6 id="返回值_2">返回值</h6>
+<p>一个{{ domxref("File") }}对象.</p>
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+<p>{{ CompatibilityTable() }}</p>
+<div id="compat-desktop">
+ <table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>8<br>
+ As <code>WebKitBlobBuilder</code> †</td>
+ <td>{{ CompatGeckoDesktop("6.0") }}<br>
+ As <code>MozBlobBuilder</code></td>
+ <td>10<br>
+ As <code>MSBlobBuilder</code></td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}†</td>
+ </tr>
+ <tr>
+ <td><code>getfile()</code> {{ non-standard_inline() }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatGeckoDesktop("8.0") }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+<div id="compat-mobile">
+ <table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>3<br>
+ As <code>WebKitBlobBuilder</code></td>
+ <td>{{ CompatGeckoMobile("6.0") }}<br>
+ As <code>MozBlobBuilder</code></td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ </tr>
+ <tr>
+ <td><code>getfile()</code> {{ non-standard_inline() }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatGeckoMobile("8.0") }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+<h3 id="注BlobBuilder已被废弃">注:BlobBuilder已被废弃</h3>
+<ul>
+ <li>从Firefox 14开始,使用<code>MozBlobBuilder</code>会在Web控制台显示一条警告消息: <code>MozBlobBuilder</code>已被废弃,请使用{{ domxref("Blob") }}来代替.</li>
+ <li>从Firefox 18开始,<code>MozBlobBuilder</code>已被删除.</li>
+ <li>WebKit has deprecated <code>WebKitBlobBuilder</code> and has made its support configurable. Currently Safari disables the feature in Nightly, so it will never likely to ship in the final version. On the other hand, Chrome, which has supported it since Chrome 8, still enables the feature. So Chrome might continue to support the feature. (See this <a class="external" href="http://trac.webkit.org/changeset/115666" title="http://trac.webkit.org/changeset/115666">WebKit changeset</a> for details).</li>
+</ul>
+<h2 id="相关链接">相关链接</h2>
+<ul>
+ <li>{{ spec("http://dev.w3.org/2009/dap/file-system/file-writer.html#idl-def-BlobBuilder", "File API Specification: BlobBuilder", "ED") }}</li>
+ <li>{{ domxref("Blob") }}</li>
+ <li>{{ domxref("File") }}</li>
+</ul>