Created
July 7, 2022 09:25
-
-
Save monjer/1f4ae86d6c7c8226023f6ecea4a79f0e to your computer and use it in GitHub Desktop.
Convert file to buffer
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
import fs from 'fs'; | |
const fileToBuffer = async (filePath) => { | |
return new Promise((resovle, reject) => { | |
fs.readFile(filePath, (error, data) => { | |
if (error) { | |
reject(error); | |
} else { | |
resovle(data); | |
} | |
}); | |
}) | |
} | |
export default fileToBuffer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment