Last active
July 15, 2019 22:52
-
-
Save merlosy/75d40441ab9e96710508590f9506e076 to your computer and use it in GitHub Desktop.
Blob to Json
This file contains 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
blobToJson(blob: Blob): Observable<any> { | |
let loadend: Observable<any>; | |
if (blob.type === 'application/json') { | |
const reader = new FileReader(); | |
loadend = fromEvent(reader, 'loadend').pipe( | |
map((read: any) => { | |
this.logger.debug('blobToJson:loadend *', JSON.parse(read.target.result)); | |
return JSON.parse(read.target.result); | |
}) | |
); | |
reader.readAsText(blob); | |
} else { | |
loadend = of({}); | |
} | |
return loadend; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment