Created
September 6, 2019 13:28
-
-
Save mccabiles/8ae33902c1f6433948137c3ce06a1577 to your computer and use it in GitHub Desktop.
Get data from file for use with <image> src.
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
const readFileData = (file) => { | |
return new Promise(resolve => { | |
if (!file instanceof File) | |
return resolve(file); | |
const reader = new FileReader(); | |
reader.addEventListener('load', function() { | |
resolve(this.result); | |
}); | |
reader.readAsDataURL(file); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment