Skip to content

getFileType

getFileType(path): undefined | "image" | "video"

获取文件类型

参数

NameTypeDescription
pathstring文件路径

返回值

undefined | "image" | "video"

示例

ts
const fileType = getFileType('/var/www/html/avatar.jpg') // 'image'
const fileType = getFileType('/var/www/html/avatar.mp4') // 'video'

源码

file.js