File System API reference

  • Revision slug: Web/Reference/File_System_API
  • Revision title: File System API reference
  • Revision id: 408585
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment

Revision Content

Asynchronous APIs

The asynchronous API has the following interfaces:

  • LocalFileSystem has two global methods that lets you request access to a sandboxed file system: requestFileSystem() and resolveLocalFileSystemURL(). The methods are implemented by both the window object and the worker global scope.
  • FileSystem represents a file system. The object is your gateway to the entire API.
  • Entry represents an entry in a file system. The entry can be a file or a directory.
  • DirectoryEntry represents a directory in a file system. 
  • DirectoryReader lets you read files and directories in a directory.
  • FileEntry represents a file on a file system.
  • FileError is an error that you might encounter while using the asynchronous methods.

Synchronous APIs

The synchronous API is for use with WebWorkers. Unlike the asynchronous API, the synchronous API does not use callbacks because the API methods return values.

  • LocalFileSystemSync has two global methods that lets you request access to a sandboxed file system: requestFileSystemSync() and  resolveLocalFileSystemSyncURL(). The methods are implemented by the worker object.
  • FileSystemSync represents a file system.
  • EntrySync represents an entry in a file system. The entry can be a file or a directory.
  • DirectoryEntrySync represents a directory on a file system. 
  • DirectoryReaderSync lets you read files and directories in a directory.
  • FileEntrySync represents a file on a file system.
  • FileException is an error that you might encounter while using the synchronous methods.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Asynchronous API 13 {{ property_prefix("webkit") }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Synchronous API 13 {{ property_prefix("webkit") }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Asynchronous API {{ CompatNo() }} 0.16{{ property_prefix("webkit") }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Synchronous API {{ CompatNo() }} 0.16{{ property_prefix("webkit") }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}

See also

Specification: {{ spec("http://dev.w3.org/2009/dap/file-system/pub/FileSystem/", "File API: Directories and System Specification", "WD") }}

Revision Source

<h2 id="Asynchronous_APIs">Asynchronous APIs</h2>
<p>The asynchronous API has the following interfaces:</p>
<ul>
  <li><code><a href="/en/DOM/File_API/File_System_API/LocalFileSystem" title="en/DOM/File_API/File_System_API/LocalFileSystem">LocalFileSystem</a></code> has two global methods that lets you request access to a sandboxed file system: <code>requestFileSystem()</code> and <code>resolveLocalFileSystemURL()</code>. The methods are implemented by both the <a href="/en/DOM/window" title="https://developer.mozilla.org/en/DOM/window"><code>window</code></a> object and the worker global scope.</li>
  <li><code><a href="/en/DOM/File_API/File_System_API/FileSystem" title="en/DOM/File_API/File_system_API/FileSystem">FileSystem</a></code> represents a file system. The object is your gateway to the entire API.</li>
  <li><code><a href="/en/DOM/File_API/File_System_API/Entry" title="en/DOM/File_API/File_system_API/Entry">Entry</a></code> represents an entry&nbsp;in a file system. The entry can be a file or a directory.</li>
  <li><code><a href="/en/DOM/File_API/File_System_API/DirectoryEntry" title="en/DOM/File_API/File_system_API/DirectoryEntry">DirectoryEntry</a></code> represents a directory in a file system.&nbsp;</li>
  <li><code><a href="/en/DOM/File_API/File_System_API/DirectoryReader" title="en/DOM/File_API/File_system_API/DirectoryReader">DirectoryReader</a></code> lets you read files and directories in a directory.</li>
  <li><code><a href="/en/DOM/File_API/File_System_API/FileEntry" title="en/DOM/File_API/File_system_API/FileEntry">FileEntry</a></code> represents a file on a file system.</li>
  <li><code><a href="/en/DOM/File_API/File_System_API/FileError" title="en/DOM/File_API/File_system_API/FileError">FileError</a></code> is an error&nbsp;that you might encounter while using the asynchronous methods.</li>
</ul>
<h2 id="Synchronous_APIs">Synchronous APIs</h2>
<p>The synchronous API is for use with&nbsp;<a href="/En/Using_web_workers" rel="internal" title="https://developer.mozilla.org/En/Using_web_workers">WebWorkers</a>. Unlike the asynchronous API, the synchronous API does not use callbacks because the API methods return values.</p>
<ul>
  <li><code><a href="/en/DOM/File_API/File_System_API/LocalFileSystemSync" title="en/DOM/File_API/File_System_API/LocalFileSystemSync">LocalFileSystemSync</a></code>&nbsp;has two global methods that lets you request access to a sandboxed file system:&nbsp;<code>requestFileSystemSync()</code>&nbsp;and&nbsp;&nbsp;<code>resolveLocalFileSystemSyncURL()</code>. The methods are implemented by the <font face="'Courier New', 'Andale Mono', monospace"><span style="line-height: normal;">worker</span></font>&nbsp;object.</li>
  <li><code><a href="/en/DOM/File_API/File_System_API/FileSystemSync" title="en/DOM/File_API/File_system_API/FileSystemSync">FileSystemSync</a></code> represents a file system.</li>
  <li><code><a href="/en/DOM/File_API/File_System_API/EntrySync" title="en/DOM/File_API/File_system_API/EntrySync">EntrySync</a></code> represents an entry in a file system. The entry can be a file or&nbsp;a directory.</li>
  <li><code><a href="/en/DOM/File_API/File_System_API/DirectoryEntrySync" title="en/DOM/File_API/File_system_API/DirectoryEntrySync">DirectoryEntrySync</a></code>&nbsp;represents a directory on a file system.&nbsp;</li>
  <li><code><a href="/en/DOM/File_API/File_System_API/DirectoryReaderSync" title="en/DOM/File_API/File_system_API/DirectoryReaderSync">DirectoryReaderSync</a></code>&nbsp;lets you read&nbsp;files and directories in a directory.</li>
  <li><code><a href="/en/DOM/File_API/File_System_API/FileEntrySync" title="en/DOM/File_API/File_system_API/FileEntrySync">FileEntrySync</a></code> represents a file on a file system.</li>
  <li><code><a href="/en/DOM/File_API/File_System_API/FileException" title="en/DOM/File_API/File_system_API/FileException">FileException</a></code> is an error&nbsp;that you might encounter while using the synchronous methods.</li>
</ul>
<h2 id="Browser_Compatibility" name="Browser_Compatibility">Browser compatibility</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 (WebKit)</th>
      </tr>
      <tr>
        <td>Asynchronous API</td>
        <td>13 {{ property_prefix("webkit") }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
      <tr>
        <td>Synchronous API</td>
        <td>13 {{ property_prefix("webkit") }}</td>
        <td>{{ CompatNo() }}</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>Chrome for Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE&nbsp;Phone</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Asynchronous API</td>
        <td>{{ CompatNo() }}</td>
        <td>0.16{{ property_prefix("webkit") }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
      <tr>
        <td>Synchronous API</td>
        <td>{{ CompatNo() }}</td>
        <td>0.16{{ property_prefix("webkit") }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
        <td>{{ CompatNo() }}</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also">See also</h2>
<p>Specification:&nbsp;{{ spec("http://dev.w3.org/2009/dap/file-system/pub/FileSystem/", "File API: Directories and System Specification", "WD") }}</p>
Revert to this revision