createBlobFromRandomAccessStream method

Creates a Blob from an IRandomAccessStream object. This method should be used when dealing with IRandomAccessStream objects in Apps in order to create a W3C based object from the stream. Once the blob is created, it can be used with the FileReader, URL APIs, and XMLHttpRequest. .

Internet Explorer 10

 

Syntax

var retVal = MSApp.createBlobFromRandomAccessStream(type, stream);

Parameters

  • type [in]
    Type: String

    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.

  • stream [in]
    Type: any

    IRandomAccessStream to be stored in the Blob.

Return value

Type: Blob

New blob object that contains the stream

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

Creates a Blobfrom Windows Runtime types via the MSApp namespace on the window object. This method will create a blob that is essentially a light wrapper over the RandomAccessStream object provided to it. The blob owns the lifetime of this stream and the stream will be closed when the blob is destroyed.

Examples

var randomAccessStream = dataPackage.GetData("image/bmp");
var blob = window.MSApp.createBlobFromRandomAccessStream("image/bmp", randomAccessStream);
var url = window.URL.createObjectURL(blob, {oneTimeOnly:true});

document.getElementById("imagetag").src = url; 

See also

MSApp