session-desktop/ts/types/MIME.ts

30 lines
1.5 KiB
TypeScript
Raw Normal View History

export type MIMEType = string;
2018-04-10 01:24:24 +02:00
2018-05-07 17:24:40 +02:00
export const APPLICATION_OCTET_STREAM = 'application/octet-stream' as MIMEType;
2018-05-07 21:49:06 +02:00
export const APPLICATION_JSON = 'application/json' as MIMEType;
2018-05-07 18:40:59 +02:00
export const AUDIO_AAC = 'audio/aac' as MIMEType;
2020-03-12 07:15:02 +01:00
export const AUDIO_WEBM = 'audio/webm' as MIMEType;
2018-05-07 18:40:59 +02:00
export const AUDIO_MP3 = 'audio/mp3' as MIMEType;
2021-03-16 01:00:22 +01:00
export const AUDIO_OPUS = 'audio/ogg' as MIMEType;
2018-05-07 17:24:40 +02:00
export const IMAGE_GIF = 'image/gif' as MIMEType;
export const IMAGE_JPEG = 'image/jpeg' as MIMEType;
export const IMAGE_BMP = 'image/bmp' as MIMEType;
export const IMAGE_ICO = 'image/x-icon' as MIMEType;
export const IMAGE_WEBP = 'image/webp' as MIMEType;
export const IMAGE_PNG = 'image/png' as MIMEType;
export const IMAGE_TIFF = 'image/tiff' as MIMEType;
export const IMAGE_UNKNOWN = 'image/unknown' as MIMEType;
2018-05-07 21:49:06 +02:00
export const VIDEO_MP4 = 'video/mp4' as MIMEType;
2018-05-07 17:24:40 +02:00
export const VIDEO_QUICKTIME = 'video/quicktime' as MIMEType;
export const ODT = 'application/vnd.oasis.opendocument.spreadsheet' as MIMEType;
2018-05-07 17:24:40 +02:00
2018-04-13 22:25:52 +02:00
export const isJPEG = (value: MIMEType): boolean => value === 'image/jpeg';
export const isImage = (value: MIMEType): boolean =>
value?.length > 0 && value.startsWith('image/');
2019-01-16 04:03:56 +01:00
export const isVideo = (value: MIMEType): boolean =>
value?.length > 0 && value.startsWith('video/');
// As of 2020-04-16 aif files do not play in Electron nor Chrome. We should only
// recognize them as file attachments.
2019-01-16 04:03:56 +01:00
export const isAudio = (value: MIMEType): boolean =>
value?.length > 0 && value.startsWith('audio/') && !value.endsWith('aiff');