UNPKG

util-helpers

Version:

一个基于业务场景的工具方法库

27 lines (24 loc) 980 B
import { isBlob, forEach } from 'ut2'; import checkFileType from './checkFileType.js'; import { isUploadFile } from './utils/file.util.js'; var config = { image: 'image/*,.jpeg,.jpg,.gif,.bmp,.png,.webp,.svg,.apng,.avif,.ico,.cur,.tif,.tiff,.jfif,.pjpeg,.pjp', audio: 'audio/*,.mp3,.wav,.aac,.flac', video: 'video/*,.mp4,.webm,.ogg,.mov,.mpg,.mpeg,.avi,.mkv,.wmv,.flv,.rm,.rmvb', pdf: 'application/pdf,.pdf', word: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,.doc,.docx', excel: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,.xls,.xlsx' }; function getFileType(file) { var type; if (isBlob(file) || isUploadFile(file)) { forEach(config, function (accept, fileType) { if (checkFileType(file, accept)) { type = fileType; return false; } }); } return type; } export { getFileType as default };