sindresorhus / file-type

Detect the file type of a file, stream, or data
MIT License
3.64k stars 345 forks source link

fileTypeFromFile are not defined in browser.d.ts #640

Closed romanhrynevych closed 1 month ago

romanhrynevych commented 1 month ago

Why I can't use this function inside my front-end app to define what mime type is file?

image
Borewit commented 1 month ago

Because fileTypeFromFile is used to access files on you local file system, which is only possible via Node.js file sytem API.

If you want to read a File (a File you uploaded in a browser environment), you can use fileTypeFromBlob(blob).

This could be better documented in the README, please keep this issue open until that is clearly captured.