Skip to content

Instantly share code, notes, and snippets.

@monjer
Created July 7, 2022 09:25
Show Gist options
  • Save monjer/1f4ae86d6c7c8226023f6ecea4a79f0e to your computer and use it in GitHub Desktop.
Save monjer/1f4ae86d6c7c8226023f6ecea4a79f0e to your computer and use it in GitHub Desktop.
Convert file to buffer
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