MCPcopy Create free account
hub / github.com/apitable/apitable / isWhatFileType

Function isWhatFileType

packages/datasheet/src/pc/utils/file_type.ts:104–125  ·  view source on GitHub ↗
(file: IFileLikeProps)

Source from the content-addressed store, hash-verified

102}
103
104export function isWhatFileType(file: IFileLikeProps) {
105 const inferredType = mime.lookup(file.name) as string;
106 if (isImage(file)) {
107 return FileType.Image;
108 }
109 if (isPdf(file)) {
110 return FileType.Pdf;
111 }
112 if (accept(file, DOC_MIME_TYPE) || DOC_MIME_TYPE.includes(inferredType)) {
113 return FileType.Doc;
114 }
115 if (accept(file, MEDIA_TYPE) && !INVALID_MEDIA_TYPE.includes(inferredType)) {
116 return FileType.Media;
117 }
118 if (accept(file, ZIPPED_TYPE)) {
119 return FileType.Zip;
120 }
121 if (accept(file, 'text/plain')) {
122 return FileType.Txt;
123 }
124 return FileType.Other;
125}
126
127export function isDocType(file: IFileLikeProps) {
128 const inferredType = mime.lookup(file.name) as string;

Callers 2

preview_type.tsxFile · 0.90
renderFileIconUrlFunction · 0.70

Calls 3

isImageFunction · 0.90
isPdfFunction · 0.90
lookupMethod · 0.65

Tested by

no test coverage detected