blob to img
socket.onmessage = function(event) {
if (event.data instanceof Blob) {
// 1. Get the raw data.
var blob = event.data;
// 2. Create a new URL for the blob object.
window.URL = window.URL || window.webkitURL;
var source = window.URL.createObjectURL(blob);
// 3. Create an image tag programmatically.
var image = document.createElement("img");
image.src = source;
image.alt = "Image generated from blob";
// 4. Insert the new image at the end of the document.
document.body.appendChild(image);
}