- From: CVS User abarsto <cvsmail@w3.org>
- Date: Sat, 19 Apr 2014 12:13:25 +0000
- To: public-dap-commits@w3.org
Update of /sources/public/2009/dap/file-system/pub/FileWriter In directory roscoe:/tmp/cvs-serv32151 Modified Files: Overview.html Log Message: This version is the April 2014 WG NOTE --- /sources/public/2009/dap/file-system/pub/FileWriter/Overview.html 2012/04/17 00:03:11 1.15 +++ /sources/public/2009/dap/file-system/pub/FileWriter/Overview.html 2014/04/19 12:13:25 1.16 @@ -1,1036 +1,256 @@ -<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'> -<html lang="en" dir="ltr"> +<!DOCTYPE html> +<html lang="en" dir="ltr" typeof="bibo:Document w3p:NOTE" about="" property="dcterms:language" content="en"> <head> <title>File API: Writer</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> - <link href="Overview_files/respec.css" rel="stylesheet" type="text/css" charset="utf-8"> - <link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css" charset="utf-8"></head> - <body style="display: inherit; "><div class="head"><p><a href="http://www.w3.org/"><img width="72" height="48" src="http://www.w3.org/Icons/w3c_home" alt="W3C"></a></p><h1 class="title" id="title">File <acronym title="Application Programming - Interface">API</acronym>: Writer</h1><h2 id="w3c-working-draft-17-april-2012"><acronym title="World Wide Web Consortium">W3C</acronym> Working Draft 17 April 2012</h2><dl><dt>This version:</dt><dd><a href="http://www.w3.org/TR/2012/WD-file-writer-api-20120417/">http://www.w3.org/TR/2012/WD-file-writer-api-20120417/</a></dd><dt>Latest published version:</dt><dd><a href="http://www.w3.org/TR/file-writer-api/">http://www.w3.org/TR/file-writer-api/</a></dd><dt>Latest editor's draft:</dt><dd><a href="http://dev.w3.org/2009/dap/file-system/file-writer.html">http://dev.w3.org/2009/dap/file-system/file-writer.html</a></dd><dt>Previous version:</dt><dd><a href="http://www.w3.org/TR/2011/WD-file-writer-api-20110419/">http://www.w3.org/TR/2011/WD-file-writer-api-20110419/</a></dd><dt>Editor:</dt><dd><a href="http://www.ofb.net/~uranium/">Eric Uhrhane</a>, <a href="http://www.google.com/">Google</a></dd> -</dl><p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2012 <a href="http://www.w3.org/"><acronym title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of Technology">MIT</acronym></a>, <a href="http://www.ercim.eu/"><acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. <acronym title="World Wide Web Consortium">W3C</acronym> <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p><hr></div> - <div id="abstract" class="introductory section"><h2>Abstract</h2> - <p> - This specification defines an <acronym title="Application Programming - Interface">API</acronym> for writing to files from web applications. - This <acronym title="Application Programming - Interface">API</acronym> is designed to be used in conjunction with, and depends on - definitions in, other APIs and elements on the web platform. Most - relevant among these are [<cite><a class="bibref" rel="biblioentry" href="#bib-FILE-API-ED">FILE-API-ED</a></cite>] and [<cite><a class="bibref" rel="biblioentry" href="#bib-WEBWORKERS-ED">WEBWORKERS-ED</a></cite>]. - </p> - <p> - This <acronym title="Application Programming - Interface">API</acronym> includes: - </p><ul> - <li> A <a href="#idl-def-BlobBuilder" class="idlType"><code>BlobBuilder</code></a> interface, which enables one to build a - <a href="#dfn-blob" class="internalDFN">Blob</a> from a String. - </li><li> A <a href="#idl-def-FileSaver" class="idlType"><code>FileSaver</code></a> interface, which provides methods to write a - <a href="#dfn-blob" class="internalDFN">Blob</a> to a file, and an event model to monitor the - progress of those writes.</li> - <li> A <a href="#idl-def-FileWriter" class="idlType"><code>FileWriter</code></a> interface, which expands on FileSaver to add - a richer set of output options.</li> - <li> A <a href="#idl-def-FileWriterSync" class="idlType"><code>FileWriterSync</code></a> interface, which provides methods to - write and modify files synchronously in a Web Worker.</li> - </ul> - <p></p> - </div><div id="sotd" class="introductory section"><h2>Status of This Document</h2><p><em>This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current <acronym title="World Wide Web Consortium">W3C</acronym> publications and the latest revision of this technical report can be found in the <a href="http://www.w3.org/TR/"><acronym title="World Wide Web Consortium">W3C</acronym> technical reports index</a> at http://www.w3.org/TR/.</em></p> - <p>This document represents the early consensus of the group on - the scope and features of the proposed File <acronym title="Application Programming - Interface">API</acronym>: Writer. Issues and - editors notes in the document highlight some of - the points on which the group is still working and would - particularly like to get feedback.</p> - <p>This document was published by the <a href="http://www.w3.org/2008/webapps/">WebApps Working Group</a> as a Working Draft. This document is intended to become a <acronym title="World Wide Web Consortium">W3C</acronym> Recommendation. If you wish to make comments regarding this document, please send them to <a href="mailto:public-webapps@w3.org">public-webapps@w3.org</a> (<a href="mailto:public-webapps-request@w3.org?subject=subscribe">subscribe</a>, <a href="http://lists.w3.org/Archives/Public/public-webapps/">archives</a>). All feedback is welcome.</p><p>Publication as a Working Draft does not imply endorsement by the <acronym title="World Wide Web Consortium">W3C</acronym> Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.</p><p>This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 <aronym title="World Wide Web Consortium">W3C</acronym> Patent Policy</a>. <acronym title="World Wide Web Consortium">W3C</acronym> maintains a <a href="http://www.w3.org/2004/01/pp-impl/42538/status" rel="disclosure">public list of any patent disclosures</a> made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the <acronym title="World Wide Web Consortium">W3C</acronym> Patent Policy</a>.</p></div><div id="toc" class="section"><h2 class="introductory">Table of Contents</h2><ul class="toc"><li class="tocline"><a href="#conformance" class="tocxref"><span class="secno">1. </span>Conformance</a></li><li class="tocline"><a hre="#terminology-and-algorithms" class="tocxref"><span class="secno">2. </span>Terminology and Algorithms</a></li><li class="tocline"><a href="#introduction" class="tocxref"><span class="secno">3. </span>Introduction</a><ul class="toc"><li class="tocline"><a href="#examples" class="tocxref"><span class="secno">3.1 </span>Examples</a></li></ul></li><li class="tocline"><a href="#the-blobbuilder-interface" class="tocxref"><span class="secno">4. </span>The <code>BlobBuilder</code> interface</a><ul class="toc"><li class="tocline"><a href="#methods" class="tocxref"><span class="secno">4.1 </span>Methods</a></li><li class="tocline"><a href="#constructor-1" class="tocxref"><span class="secno">4.2 </span>Constructor</a></li></ul></li><li class="tocline"><a href="#the-filesaver-interface" class="tocxref"><span class="secno">5. </span>The <span class="idlType formerLink idlType"><code>FileSaver</code></span> interface</a><ul class="toc"><li class="tocline"><a href="#attributes" class="tocxref"><span class="secno">5.1 </pan>Attributes</a></li><li class="tocline"><a href="#methods-1" class="tocxref"><span class="secno">5.2 </span>Methods</a></li><li class="tocline"><a href="#constants" class="tocxref"><span class="secno">5.3 </span>Constants</a></li><li class="tocline"><a href="#the-filesaver-constructor" class="tocxref"><span class="secno">5.4 </span>The FileSaver Constructor</a></li><li class="tocline"><a href="#the-filesaver-task-source" class="tocxref"><span class="secno">5.5 </span>The FileSaver Task Source</a></li><li class="tocline"><a href="#event-handler-attributes" class="tocxref"><span class="secno">5.6 </span>Event Handler Attributes</a></li></ul></li><li class="tocline"><a href="#the-filesaversync-interface" class="tocxref"><span class="secno">6. </span>The <code>FileSaverSync</code> interface</a></li><li class="tocline"><a href="#the-filewriter-interface" class="tocxref"><span class="secno">7. </span>The <span class="idlType formerLink idlType"><code>FileWriter</code></span> interface</a><ul class="toc"><li clss="tocline"><a href="#attributes-1" class="tocxref"><span class="secno">7.1 </span>Attributes</a></li><li class="tocline"><a href="#methods-2" class="tocxref"><span class="secno">7.2 </span>Methods</a></li></ul></li><li class="tocline"><a href="#the-filewritersync-interface" class="tocxref"><span class="secno">8. </span>The <code>FileWriterSync</code> interface</a><ul class="toc"><li class="tocline"><a href="#attributes-2" class="tocxref"><span class="secno">8.1 </span>Attributes</a></li><li class="tocline"><a href="#methods-3" class="tocxref"><span class="secno">8.2 </span>Methods</a></li></ul></li><li class="tocline"><a href="#errors-and-exceptions" class="tocxref"><span class="secno">9. </span>Errors and Exceptions</a><ul class="toc"><li class="tocline"><a href="#occurrence" class="tocxref"><span class="secno">9.1 </span>Occurrence</a></li><li class="tocline"><a href="#definitions" class="tocxref"><span class="secno">9.2 </span>Definitions</a></li></ul></li><li class="tocline"><a href="#security-consideations" class="tocxref"><span class="secno">10. </span>Security Considerations</a><ul class="toc"><li class="tocline"><a href="#basic-security-model" class="tocxref"><span class="secno">10.1 </span>Basic Security Model</a></li><li class="tocline"><a href="#write-only-files" class="tocxref"><span class="secno">10.2 </span>Write-Only Files</a></li><li class="tocline"><a href="#quotas" class="tocxref"><span class="secno">10.3 </span>Quotas</a></li><li class="tocline"><a href="#other-standard-techniques" class="tocxref"><span class="secno">10.4 </span>Other Standard Techniques</a></li></ul></li><li class="tocline"><a href="#acknowledgements" class="tocxref"><span class="secno">A. </span>Acknowledgements</a></li><li class="tocline"><a href="#references" class="tocxref"><span class="secno">B. </span>References</a><ul class="toc"><li class="tocline"><a href="#normative-references" class="tocxref"><span class="secno">B.1 </span>Normative references</a></li><li class="tocline"><a href="#informative-references" class"tocxref"><span class="secno">B.2 </span>Informative references</a></li></ul></li></ul></div> + <style>/***************************************************************** + * ReSpec 3 CSS + * Robin Berjon - http://berjon.com/ + *****************************************************************/ - - - <div id="conformance" class="section"><!--OddPage--><h2><span class="secno">1. </span>Conformance</h2><p>As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.</p> -<p>The key words <em class="rfc2119" title="must">must</em>, <em class="rfc2119" title="must not">must not</em>, <em class="rfc2119" title="required">required</em>, <em class="rfc2119" title="should">should</em>, <em class="rfc2119" title="should not">should not</em>, <em class="rfc2119" title="recommended">recommended</em>, <em class="rfc2119" title="may">may</em>, and <em class="rfc2119" title="optional">optional</em> in this specification are to be interpreted as described in [<cite><a class="bibref" rel="biblioentry" href="#bib-RFC2119">RFC2119</a></cite>].</p> +/* --- INLINES --- */ +em.rfc2119 { + text-transform: lowercase; + font-variant: small-caps; + font-style: normal; + color: #900; +} - <p> - This specification defines conformance criteria that apply to a single - product: <a href="#dfn-user-agent" class="internalDFN">user agent</a>s that implement the interfaces that it - contains. - </p> +h1 acronym, h2 acronym, h3 acronym, h4 acronym, h5 acronym, h6 acronym, a acronym, +h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr { + border: none; +} - <p> - Everything in this specification is normative except for examples and - sections marked as being informative. - </p> +dfn { + font-weight: bold; +} - <p> - The keywords <em class="rfc2119" title="must">must</em>, <em class="rfc2119" title="must not">must not</em>, <em class="rfc2119" title="required">required</em>, <em class="rfc2119" title="shall">shall</em>, <em class="rfc2119" title="shall not">shall not</em>, <em class="rfc2119" title="should">should</em>, <em class="rfc2119" title="should - not">should - not</em>, <em class="rfc2119" title="recommended">recommended</em>, <em class="rfc2119" title="may">may</em>, and <em class="rfc2119" title="optional">optional</em> in this document are to be - interpreted as described in <a href="http://www.ietf.org/rfc/rfc2119">Key words for use in RFCs to - Indicate Requirement Levels</a> [<cite><a class="bibref" rel="biblioentry" href="#bib-RFC2119">RFC2119</a></cite>]. - </p> +a.internalDFN { + color: inherit; + border-bottom: 1px solid #99c; + text-decoration: none; +} - <p> - The following conformance classes are defined by this specification: - </p><dl> - <dt><dfn id="dfn-conforming-implementation">conforming implementation</dfn></dt> - <dd> - <p> - A <dfn id="dfn-user-agent">user agent</dfn> is considered to be a conforming - implementation if it satisfies all of the must-, required- and - shall-level criteria in this specification that apply to - implementations. - </p> - </dd> - </dl> - <p></p> - </div> - - <div id="terminology-and-algorithms" class="section"> - <!--OddPage--><h2><span class="secno">2. </span>Terminology and Algorithms</h2> - <p> - The terms and algorithms <dfn id="dfn-event-handler-attributes">event handler attributes</dfn>, <dfn id="dfn-event-handler-event-types">event - handler event types</dfn>, <dfn id="dfn-function">Function</dfn>, <dfn id="dfn-task">task</dfn>, - <dfn id="dfn-task-queue">task queue</dfn>, <dfn id="dfn-task-source">task source</dfn>, and <dfn id="dfn-queue-a-task">queue a - task</dfn> are defined by the HTML 5 specification [<cite><a class="bibref" rel="biblioentry" href="#bib-HTML5">HTML5</a></cite>]. - </p> - <p> - When this specification refers to a <dfn id="dfn-write-method">write method</dfn>, it includes - both <code>write</code> and <code>truncate</code>. - </p> - <p> - When this specification refers to a <dfn id="dfn-write-algorithm">write algorithm</dfn>, it - includes the algorithm invoked by any <a href="#dfn-write-method" class="internalDFN">write method</a> as well as the - <a href="#dfn-filesaver-write-algorithm" class="internalDFN">FileSaver write algorithm</a>. - </p> - <p> - When this specification says to <dfn id="dfn-terminate">terminate</dfn> an algorithm the - user agent must terminate the algorithm after finishing the step it is - on. Any <a href="#dfn-write-algorithm" class="internalDFN">write algorithm</a> defined in this specification can be - terminated by an abort() call. - </p> - <p> - When this specification says to <dfn id="dfn-make-progress-notifications">make progress notifications</dfn>, - the following are normative: - </p><ul> - <li>While the <a href="#dfn-write-method" class="internalDFN">write method</a> is processing, <a href="#dfn-queue-a-task" class="internalDFN">queue a task</a> - to <a href="#dfn-fire-a-progress-event" class="internalDFN">fire a progress event</a> called <code>progress</code> at the - <a href="#idl-def-FileSaver" class="idlType"><code>FileSaver</code></a> object about every 50ms or for every byte written, - whichever is less frequent.</li> - <li>At least one event called <code>progress</code> - <em class="rfc2119" title="must">must</em> fire before <code>write</code> is fired, and at 100% completion - of the write operation; if 100% of the file can written in less than - 50ms, user agents <em class="rfc2119" title="must">must</em> fire a progress event called - <code>progress</code> at completion.</li> - </ul> - <p></p> - <p> - When this specification says to <dfn id="dfn-fire-a-progress-event">fire a progress event</dfn> called - <code>e</code> (for some <code>ProgressEvent</code> <code>e</code>), the - following are normative: - </p><ul> - <li>The progress event <code>e</code> does not bubble. - <code>e.bubbles</code> <em class="rfc2119" title="must">must</em> be false [<cite><a class="bibref" rel="biblioentry" href="#bib-DOM4">DOM4</a></cite>].</li> - <li>The progress event <code>e</code> is NOT cancelable. - <code>e.cancelable</code> <em class="rfc2119" title="must">must</em> be false [<cite><a class="bibref" rel="biblioentry" href="#bib-DOM4">DOM4</a></cite>].</li> - <li>The term "fire an event" is defined in DOM4 [<cite><a class="bibref" rel="biblioentry" href="#bib-DOM4">DOM4</a></cite>]. - Progress events are defined in Progress Events - [<cite><a class="bibref" rel="biblioentry" href="#bib-PROGRESS-EVENTS-ED">PROGRESS-EVENTS-ED</a></cite>].</li> - </ul> - <p></p> - The term <dfn id="dfn-throw">throw</dfn> in this specification, as it pertains to - exceptions, is used as defined in the DOM4 specification [<cite><a class="bibref" rel="biblioentry" href="#bib-DOM4">DOM4</a></cite>]. - <p> - </p> - <p> - The term <dfn id="dfn-blob">Blob</dfn> is defined by the File <acronym title="Application Programming - Interface">API</acronym> specification - [<cite><a class="bibref" rel="biblioentry" href="#bib-FILE-API-ED">FILE-API-ED</a></cite>]. - </p> - <p> - The term <dfn id="dfn-arraybuffer">ArrayBuffer</dfn> is defined by the Typed Arrays - specification [<cite><a class="bibref" rel="biblioentry" href="#bib-TYPED-ARRAYS">TYPED-ARRAYS</a></cite>]. - </p> - <p> - This specification includes algorithms (steps) as part of the definition - of methods. Conforming implementations (referred to as <dfn id="dfn-user-agents">user - agents</dfn> from here on) <em class="rfc2119" title="may">may</em> use other algorithms in the - implementation of these methods, provided the end result is the same. - </p> - </div> +a.externalDFN { + color: inherit; + border-bottom: 1px dotted #ccc; + text-decoration: none; +} + +a.bibref { + text-decoration: none; +} + +cite .bibref { + font-style: normal; +} + +code { + color: #ff4500; +} + +/* --- TOC --- */ +.toc a, .tof a { + text-decoration: none; +} + +a .secno, a .figno { + color: #000; +} + +ul.tof, ol.tof { + list-style: none outside none; +} + +.caption { + margin-top: 0.5em; + font-style: italic; +} + +/* --- TABLE --- */ +table.simple { + border-spacing: 0; + border-collapse: collapse; + border-bottom: 3px solid #005a9c; +} + +.simple th { + background: #005a9c; + color: #fff; + padding: 3px 5px; + text-align: left; +} + +.simple th[scope="row"] { + background: inherit; + color: inherit; + border-top: 1px solid #ddd; +} + +.simple td { + padding: 3px 10px; + border-top: 1px solid #ddd; +} + +.simple tr:nth-child(even) { + background: #f0f6ff; +} + +/* --- DL --- */ +.section dd > p:first-child { + margin-top: 0; +} + +.section dd > p:last-child { + margin-bottom: 0; +} + +.section dd { + margin-bottom: 1em; +} + +.section dl.attrs dd, .section dl.eldef dd { + margin-bottom: 0; +} + +@media print { + .removeOnSave { + display: none; + } +} +</style><link rel="stylesheet" href="https://www.w3.org/StyleSheets/TR/W3C-NOTE"><!--[if lt IE 9]><script src='https://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]--></head> + <body class="h-entry" role="document" id="respecDocument"><div class="head" role="contentinfo" id="respecHeader"> + <p> - <div class="informative section" id="introduction"> - <!--OddPage--><h2><span class="secno">3. </span>Introduction</h2><p><em>This section is non-normative.</em></p> - <p> - Web applications are currently fairly limited in how they can write to - files. One can present a link for download, but creating and writing - files of arbitrary type, or modifying downloaded files on their way to - the disk, is difficult or impossible. This specification defines an - <acronym title="Application Programming - Interface">API</acronym> through which <a href="#dfn-user-agent" class="internalDFN">user agent</a>s can permit applications to write - generated or downloaded files. - </p> - <p> - The [<cite><a class="bibref" rel="biblioentry" href="#bib-FILE-API-ED">FILE-API-ED</a></cite>] defined interfaces for reading files, manipulation - of <a>Blobs</a> of data, and errors raised by file accesses. This - specification extends that work with a way to construct <a>Blobs</a> and - with synchronous and asynchronous file-writing interfaces. As with - reading, writing files on the main thread should happen asynchronously - to avoid blocking UI actions. Long-running writes provide status - information through delivery of <a>progress events</a>. + <a href="http://www.w3.org/"><img width="72" height="48" src="https://www.w3.org/Icons/w3c_home" alt="W3C"></a> + + </p> + <h1 class="title p-name" id="title" property="dcterms:title">File <abbr title="Application Programming + Interface">API</abbr>: Writer</h1> + + <h2 property="dcterms:issued" datatype="xsd:dateTime" content="2014-04-24T04:00:00.000Z" id="w3c-working-group-note-24-april-2014"><abbr title="World Wide Web Consortium">W3C</abbr> Working Group Note <time class="dt-published" datetime="2014-04-24">24 April 2014</time></h2> + <dl> + + <dt>This version:</dt> + <dd><a class="u-url" href="http://www.w3.org/TR/2014/NOTE-file-writer-api-20140424/">http://www.w3.org/TR/2014/NOTE-file-writer-api-20140424/</a></dd> + <dt>Latest published version:</dt> + <dd><a href="http://www.w3.org/TR/file-writer-api/">http://www.w3.org/TR/file-writer-api/</a></dd> + + <dt>Latest editor's draft:</dt> + <dd><a href="http://dev.w3.org/2009/dap/file-system/file-writer.html">http://dev.w3.org/2009/dap/file-system/file-writer.html</a></dd> + + <dt>Previous version:</dt> + <dd><a href="http://www.w3.org/TR/2012/WD-file-writer-api-20120417/">http://www.w3.org/TR/2012/WD-file-writer-api-20120417/</a></dd> + + <dt>Editor:</dt> + <dd class="p-author h-card vcard" rel="bibo:editor" inlist=""><span typeof="foaf:Person"><a class="u-url url p-name fn" rel="foaf:homepage" property="foaf:name" content="Eric Uhrhane" href="http://www.ofb.net/~uranium/">Eric Uhrhane</a>, <a rel="foaf:workplaceHomepage" class="p-org org h-org h-card" href="http://www.google.com/">Google</a></span> +</dd> + + </dl> + + <p class="copyright"> + <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © + 2014 + + <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> + (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, + <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, + <a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>), + + All Rights Reserved. + + <abbr title="World Wide Web Consortium">W3C</abbr> <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, + <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and + + <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> + + rules apply. </p> - <div id="examples" class="section"> - <h3><span class="secno">3.1 </span>Examples</h3> + + + <hr> +</div> + <section id="abstract" class="introductory" property="dcterms:abstract" datatype="" typeof="bibo:Chapter" resource="#abstract" rel="bibo:Chapter"> + + <h2 aria-level="1" role="heading" id="h2_abstract">Abstract</h2> + <p> + This specification defines an <abbr title='Application Programming + Interface'>API</abbr> for writing to files from web applications. + This API is designed to be used in conjunction with, and depends on + definitions in, other APIs and elements on the web platform. Most + relevant among these are + <a href="http://www.w3.org/TR/FileAPI/">File API</a> and + <a href="http://www.w3.org/TR/workers/">Web Workers</a>. + </p> + </section> + + <section id="sotd" class="introductory" typeof="bibo:Chapter" resource="#sotd" rel="bibo:Chapter"><h2 aria-level="1" role="heading" id="h2_sotd">Status of This Document</h2> + <p> - Here is a simple function that writes a text file, given a FileWriter: + <em>This section describes the status of this document at the time of its publication. + Other documents may supersede this document. A list of current <abbr title="World Wide Web Consortium">W3C</abbr> publications and the + latest revision of this technical report can be found in the <a href="http://www.w3.org/TR/"><abbr title="World Wide Web Consortium">W3C</abbr> technical reports index</a> at + http://www.w3.org/TR/.</em> </p> - <pre class="example sh_javascript sh_sourceCode"><span class="sh_keyword">function</span> <span class="sh_function">writeFile</span><span class="sh_symbol">(</span>writer<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span> - <span class="sh_keyword">function</span> <span class="sh_function">done</span><span class="sh_symbol">(</span>evt<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span> - <span class="sh_function">alert</span><span class="sh_symbol">(</span><span class="sh_string">"Write completed."</span><span class="sh_symbol">);</span> - <span class="sh_cbracket">}</span> - <span class="sh_keyword">function</span> <span class="sh_function">error</span><span class="sh_symbol">(</span>evt<span class="sh_symbol">)</span> <span class="sh_cbracket">{</span> - <span class="sh_function">alert</span><span class="sh_symbol">(</span><span class="sh_string">"Write failed:"</span> <span class="sh_symbol">+</span> evt<span class="sh_symbol">);</span> - <span class="sh_cbracket">}</span> - - <span class="sh_keyword">var</span> bb <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> <span class="sh_function">BlobBuilder</span><span class="sh_symbol">();</span> - bb<span class="sh_symbol">.</span><span class="sh_function">append</span><span class="sh_symbol">(</span><span class="sh_string">"Lorem ipsum"</span><span class="sh_symbol">);</span> - writer<span class="sh_symbol">.</span>onwrite <span class="sh_symbol">=</span> done<span class="sh_symbol">;</span> - writer<span class="sh_symbol">.</span>onerror <span class="sh_symbol">=</span> error<span class="sh_symbol">;</span> - writer<span class="sh_symbol">.</span><span class="sh_function">write</span><span class="sh_symbol">(</span>bb<span class="sh_symbol">.</span><span class="sh_function">getBlob</span><span class="sh_symbol">());</span> -<span class="sh_cbracket">}</span></pre> + + <p><strong>Work on this document has been discontinued and it should not be + referenced or used as a basis for implementation.</strong></p> + <p> - Here's an example of obtaining and using a <a href="#idl-def-FileSaver" class="idlType"><code>FileSaver</code></a>: - </p> - <pre class="example sh_javascript sh_sourceCode"><span class="sh_keyword">var</span> bb <span class="sh_symbol">=</span> <span class="sh_keyword">new</span> <span class="sh_function">BlobBuilder</span><span class="sh_symbol">();</span> -bb<span class="sh_symbol">.</span><span class="sh_function">append</span><span class="sh_symbol">(</span><span class="sh_string">"Lorem ipsum"</span><span class="sh_symbol">);</span> -<span class="sh_keyword">var</span> fileSaver <span class="sh_symbol">=</span> window<span class="sh_symbol">.</span><span class="sh_function">saveAs</span><span class="sh_symbol">(</span>bb<span class="sh_symbol">.</span><span class="sh_function">getBlob</span><span class="sh_symbol">(),</span> <span class="sh_string">"test_file"</span><span class="sh_symbol">);</span> -fileSaver<span class="sh_symbol">.</span>onwriteend <span class="sh_symbol">=</span> myOnWriteEnd<span class="sh_symbol">;</span></pre> - <p></p> - </div> - </div> - - <div id="the-blobbuilder-interface" class="section"> - <!--OddPage--><h2><span class="secno">4. </span>The <code>BlobBuilder</code> interface</h2> - <p> [864 lines skipped]
Received on Saturday, 19 April 2014 12:13:27 UTC