Created
December 10, 2020 11:38
-
-
Save Ref-Bit/d3f4f7153f6a882f369b32c8a455f9b5 to your computer and use it in GitHub Desktop.
This is a function to convert file to base64 upon upload
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
const convertFileToBase64 = file => | |
new Promise((resolve, reject) => { | |
const reader = new FileReader(); | |
reader.readAsDataURL(file); | |
reader.onload = () => resolve(reader.result); | |
reader.onerror = error => reject(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment