MSStream object

Represents binary data in JavaScript.

Syntax


var stream = stream.DetachStream;

DOM Information

Inheritance Hierarchy

The MSStream does not inherit from any class or interface.

Members

The MSStream object has these types of members:

Methods

The MSStream object has these methods.

MethodDescription
msClose

Closes the Blob object by releasing the stream held by the Blob and the associated file or memory resource.

msDetachStream

Detaches the IInputStream object from the MSStream in order to use the backing IInputStream object in other WinRT APIs.

 

Properties

The MSStream object has these properties.

PropertyDescription

type

Returns the content type of the object.

 

Remarks

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 IInputSteam winrt objects. MSStream is backed by IInputStream.

The MSStream object also allows Interop with XHR and HTML tags for the IInputStream WinRT object.

An MSStream is consumed or created in the following areas:

  • XmlHttpRequest (XHR)
  • MSApp.createStreamFromInputStream

You create a Uniform Resource Identifier (URI) for the MSStream object using the window.URL.createObjectURL method. MSStream is intended for a one-time use only; the URI is revoked when it is resolved by the HTML element that is consuming the stream.

Examples

The following shows how to get an MSStream from XMLHttpRequest in ready state 3 which is before the data has been fully downloaded. The example then goes on to show how you could obtain the IInputStream from the MSStream object for use with other WinRT APIs.


var xhrRequest;

function readyStateCallback() {
  if (xhrRequest.readyState == 3 && xhrRequest.status == 200 ) {
    var msstream = xhrRequest.response; // MSStream object
    var stream = msstream.msDetachStream(); // IInputStreamObject
	   
    doSomething(stream);
  }
}

function downloadBlob() {          
  xhrRequest = new XMLHttpRequest();

  if (xhrRequest) {
    xhrRequest.open("GET", "http://myserver/myfile", true);
    xhrRequest.responseType = "ms-stream";
    xhrRequest.onreadystatechange = readyStateCallback;
    xhrRequest.send(null);
  }
}

 

 

Show:
© 2014 Microsoft