remove preview for all file except images
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
export const getFileType = (fileName: string, allowedExtensions: {
|
||||
images: string[],
|
||||
videos: string[],
|
||||
audios: string[],
|
||||
documents: string[]
|
||||
}): 'image' | 'video' | 'audio' | 'document' | 'unknown' => {
|
||||
|
||||
const lastDotIndex = fileName.lastIndexOf('.');
|
||||
const extension = fileName.substring(lastDotIndex + 1).toLowerCase();
|
||||
|
||||
if (allowedExtensions.images.includes(extension)) {
|
||||
return 'image';
|
||||
}
|
||||
|
||||
if (allowedExtensions.videos.includes(extension)) {
|
||||
return 'video';
|
||||
}
|
||||
|
||||
if (allowedExtensions.audios.includes(extension)) {
|
||||
return 'audio';
|
||||
}
|
||||
|
||||
if (allowedExtensions.documents.includes(extension)) {
|
||||
return 'document';
|
||||
}
|
||||
|
||||
return 'unknown';
|
||||
}
|
||||
Reference in New Issue
Block a user