130 lines
2.5 KiB
TypeScript
130 lines
2.5 KiB
TypeScript
/**
|
|
* File Extensions Constants
|
|
* Categorizes common file extensions for use throughout the application
|
|
*/
|
|
|
|
// Image file extensions
|
|
export const IMAGE_EXTENSIONS = [
|
|
'jpg',
|
|
'jpeg',
|
|
'png',
|
|
'gif',
|
|
'bmp',
|
|
'webp',
|
|
'svg',
|
|
'tiff',
|
|
'ico'
|
|
];
|
|
|
|
// Document file extensions
|
|
export const DOCUMENT_EXTENSIONS = [
|
|
'pdf',
|
|
'doc',
|
|
'docx',
|
|
'xls',
|
|
'xlsx',
|
|
'ppt',
|
|
'pptx',
|
|
'txt',
|
|
'rtf',
|
|
'odt',
|
|
'ods',
|
|
'odp',
|
|
'csv',
|
|
'xml',
|
|
'html',
|
|
'htm'
|
|
];
|
|
|
|
// Video file extensions
|
|
export const VIDEO_EXTENSIONS = [
|
|
'mp4',
|
|
'avi',
|
|
'mov',
|
|
'wmv',
|
|
'flv',
|
|
'webm',
|
|
'mkv',
|
|
'm4v',
|
|
'3gp',
|
|
'mpeg',
|
|
'mpg'
|
|
];
|
|
|
|
// Audio file extensions
|
|
export const AUDIO_EXTENSIONS = [
|
|
'mp3',
|
|
'wav',
|
|
'flac',
|
|
'aac',
|
|
'ogg',
|
|
'wma',
|
|
'm4a',
|
|
'opus'
|
|
];
|
|
|
|
// Archive file extensions
|
|
export const ARCHIVE_EXTENSIONS = [
|
|
'zip',
|
|
'rar',
|
|
'7z',
|
|
'tar',
|
|
'gz',
|
|
'bz2',
|
|
'xz',
|
|
'iso',
|
|
'dmg'
|
|
];
|
|
|
|
// Combined list of all extensions
|
|
export const ALL_EXTENSIONS = [
|
|
...IMAGE_EXTENSIONS,
|
|
...DOCUMENT_EXTENSIONS,
|
|
...VIDEO_EXTENSIONS,
|
|
...AUDIO_EXTENSIONS,
|
|
...ARCHIVE_EXTENSIONS
|
|
];
|
|
|
|
// Helper function to get file type category based on extension
|
|
export const getFileTypeCategory = (extension: string): string => {
|
|
const ext = extension.toLowerCase();
|
|
|
|
if (IMAGE_EXTENSIONS.includes(ext)) {
|
|
return 'image';
|
|
} else if (DOCUMENT_EXTENSIONS.includes(ext)) {
|
|
return 'document';
|
|
} else if (VIDEO_EXTENSIONS.includes(ext)) {
|
|
return 'video';
|
|
} else if (AUDIO_EXTENSIONS.includes(ext)) {
|
|
return 'audio';
|
|
} else if (ARCHIVE_EXTENSIONS.includes(ext)) {
|
|
return 'archive';
|
|
}
|
|
|
|
return 'unknown';
|
|
};
|
|
|
|
// Helper function to check if a file is an image
|
|
export const isImageFile = (extension: string): boolean => {
|
|
return IMAGE_EXTENSIONS.includes(extension.toLowerCase());
|
|
};
|
|
|
|
// Helper function to check if a file is a document
|
|
export const isDocumentFile = (extension: string): boolean => {
|
|
return DOCUMENT_EXTENSIONS.includes(extension.toLowerCase());
|
|
};
|
|
|
|
// Helper function to check if a file is a video
|
|
export const isVideoFile = (extension: string): boolean => {
|
|
return VIDEO_EXTENSIONS.includes(extension.toLowerCase());
|
|
};
|
|
|
|
// Helper function to check if a file is audio
|
|
export const isAudioFile = (extension: string): boolean => {
|
|
return AUDIO_EXTENSIONS.includes(extension.toLowerCase());
|
|
};
|
|
|
|
// Helper function to check if a file is an archive
|
|
export const isArchiveFile = (extension: string): boolean => {
|
|
return ARCHIVE_EXTENSIONS.includes(extension.toLowerCase());
|
|
}; |