I was following a youtube tutorial on file upload using multer. From the video, changing the extension doesn't change the file's mimetype. Only that upon replicating the process, the original file was a json file with the following information,
{
fieldname: 'images',
originalname: 'budg.ods',
encoding: '7bit',
mimetype: 'application/vnd.oasis.opendocument.spreadsheet',
destination: './uploads',
filename: '597077caac33d200e499f1b1fed1b7d7',
path: 'uploads/597077caac33d200e499f1b1fed1b7d7',
size: 12213
}
On changing the extension of the same file, I got the following
{
originalname: 'budg.png',
encoding: '7bit',
mimetype: 'image/png',
filename: 'c05f55e6168dd1a22cfd1fa29e69ed1c',
size: 12213,
...
}
Is the video's implementation the right way of checking a file's mimetype, regardless of the extension, and if not, what's a better alternative?