179
rated 0 times
[
183]
[
4]
/ answers: 1 / hits: 6058
/ 4 Years ago, sat, january 11, 2020, 12:00:00
I tried finding type of file using file-type module but when i try to run it gives me error that error:.... fileType.fromBuffer is not a function.
`
const fileType = require('file-type');
const readChunk = require('read-chunk');
exports.ext = async function(file) {
const buffer = readChunk.sync(file, 0, 512)
let type = await fileType.fromBuffer(buffer);
console.log(type of file,type)
return value
`
this is in utils.js file and i am calling it in other type.js file
`
var extension = await utils.ext('ABC.png')
console.log(extension)
`
Can anybody tell me what should i do?
More From » node.js