2

So, I have a blob as a txt inside a zip. I can access the txt file but I cant open it. I've installed by npm the FileReader and tried something that I saw here on stackoverflow https://stackoverflow.com/questions/23024460/javascript-i-created-a-blob-from-a-string-how-do-i-get-the-string-back-out, but I get nothing neither alerts or logs.

convertInText = (blob) => {

        let reader = new FileReader();
        reader.readAsText(blob, "ANSI");
        reader.onloadend = function(e) {
            console.log(reader.result);
        };

    };

Also imported FileReader and all but no result.

Nelson Silva
  • 429
  • 7
  • 22
  • This isn't a valid code sample. Where is blob defined, no link to what you tried on stack, I don't see how you expect to see anything in a log? Where is the log statement.. You need some more samples here. – Dylan Wright Apr 26 '18 at 11:54
  • @DylanWright that is what I used from stack, updated with the link and the method. Alert/console.log, was just to tell that I tried both. What would be the purpose of having both? Thought it was obvious that would go to where the alert is. – Nelson Silva Apr 26 '18 at 13:02
  • 1
    What do you mean by "I installed by NPM FileReader"? When you look at the listed Stack Question you provided a link to there is a link to MDN FileReader API.. not a npm package. There is also a JSFiddle in the comment of the answer, http://jsfiddle.net/dnmSR/ with a working sample – Dylan Wright Apr 26 '18 at 13:11
  • 1
    If you're still having an issue your file may have some kind of read/write permission on it or possible it's open somewhere else by another process. – Dylan Wright Apr 26 '18 at 13:12
  • Oh my bad, was using the URL instead of the object Blob itself, figured that out using that jsfiddle. Thanks! – Nelson Silva Apr 26 '18 at 13:29
  • 1
    No problem and good luck – Dylan Wright Apr 26 '18 at 13:47

0 Answers0