File API

The File API, currently being standardized by the World Wide Web Consortium (W3C), represents file objects in web applications and allows access to file information via JavaScript and an input[type=file] element. By using File API, web developers can access local files on the client machine in a secure way without the need for extensions or plugins.

The File API allows a browser or app to read and manipulate files but only if the user provides permission to do so. Additionally, the File API allows for smoother file upload experiences without plugins.

Multiple file uploads (4 GB per file) with file type filtering is also supported. In the following example, multiple GIF or JPEG files can be selected by the user:

<input type="file" name="pic" multiple accept="image/gif, image/jpeg" />

For more information, see the File Upload state (type=file) section within the HTML5 spec.

File API Example

The following code example acquires basic file-related information such as name, type, and size.

See this example by Microsoft Edge Docs on CodePen.

Blob constructor

The Blob constructor enables a web developer to create or manipulate a Blob (often equivalent to a file) directly on the client. The constructor is defined in the W3C's File API spec.

Check out the Blob Dev Guide entry for more details.

FileReader object

The FileReader object lets you asynchronously read individual File or Blob objects by firing progress events as the read occurs to event handler methods attached to the FileReader object. Because of the asynchronous reading, it is possible to catch errors, know when a load is complete, and monitor the read progress.

For more details check out the FileReader Dev Guide entry!

Streams

The Steams API is based off of the W3C Streams API specification, and is supported in the ms-prefixed form, MSStream.

The MSStream object is a Document Object Model (DOM) type that represents a stream of unsized, sequential binary data. You use the MSStream object for data that is streaming over the network which hasn't completed downloaded yet, or as an analogous type to IInputStream WinRT objects. MSStream is backed by IInputStream.

When you get MSStream from HTML5 API (like an XmlHttpRequest with a responseType of “ms-stream”, as you’d use when downloading a file or video), you can pass those results to various WinRT APIs that accept IInputStream or IRandomAccessStream as input.

API Reference

File API

Specification

File API