Created
February 7, 2014 13:22
-
-
Save moro-programmer/8862549 to your computer and use it in GitHub Desktop.
blob to img
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment