Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I console.log() a Blob object?

I have a Blob object I want to inspect by logging its value. All I can see are type and size properties. Is there a way to do this?

console.logging a blob shows this

like image 236
jkjustjoshing Avatar asked Dec 30 '14 18:12

jkjustjoshing


Video Answer


1 Answers

Basic example on using a FileReader to look at the content in a blob

var html= ['<a id="anchor">Hello World</a>'];
var myBlob = new Blob(html, { type: 'text/xml'});
var myReader = new FileReader();
myReader.onload = function(event){
    console.log(JSON.stringify(myReader.result));
};
myReader.readAsText(myBlob);
like image 94
epascarello Avatar answered Sep 28 '22 05:09

epascarello