createStreamFromInputStream method

Creates an MSStream from an InputStream.

Internet Explorer 10

 

Syntax

var retVal = MSApp.createStreamFromInputStream(type, inputStream);

Parameters

  • type [in]
    Type: DOMString

    Content type of the data. This string should be in the format specified in the media-type token defined in section 3.7 of RFC 2616.

  • inputStream [in]
    Type: any

    The IInputStream to be stored in the MSStream.

Exceptions

Exception Condition
TypeMismatchError

The node type is incompatible with the expected parameter type. For versions earlier than Internet Explorer 10, TYPE_MISMATCH_ERR is returned.

 

Remarks

This method takes a content-type, and the IInputStream reference. The method then verifies that the stream reference passed in is an instance of type IInputStream and if not, throws DOMException TYPE_MISMATCH_ERR. If no error occurs, createStreamFromInputStream creates an MSStream (from its inputs).

Examples

An IInputStream can be used to create an MSStream. As MSStreams are inherently one-time-use objects, all URLs created by URL.createObjectURL are revoked the first time it's resolved by the image element. Additionally, requests for a second URL on this object after the stream has been used will fail.

var inputStream = myInputStream; //get InputStream from socket API, etc.
var stream = MSApp.createStreamFromInputStream("image/bmp", inputstream);
document.getElementById("imagetag").src = URL.createObjectURL(stream); 

See also

MSApp