1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00
vault-frontend/src/constants/uploads/index.ts
2022-08-09 17:36:29 +07:00

57 lines
1 KiB
TypeScript

import { IFile } from '~/types';
export const EMPTY_FILE: IFile = {
id: 0,
user_id: undefined,
node_id: undefined,
name: '',
orig_name: '',
path: '',
full_path: '',
url: '',
size: 0,
type: undefined,
mime: '',
};
// for targeted cancellation
export enum UploadSubject {
Editor = 'editor',
Comment = 'comment',
Avatar = 'avatar',
}
export enum UploadTarget {
Nodes = 'nodes',
Comments = 'comments',
Profiles = 'profiles',
Others = 'other',
}
export enum UploadType {
Image = 'image',
Audio = 'audio',
Video = 'video',
Other = 'other',
}
export const FILE_MIMES: Record<UploadType, string[]> = {
[UploadType.Video]: [],
[UploadType.Image]: [
'image/jpeg',
'image/jpg',
'image/png',
'image/svg+xml',
'image/webp',
],
[UploadType.Audio]: ['audio/mpeg3', 'audio/mpeg', 'audio/mp3'],
[UploadType.Other]: [],
};
export const COMMENT_FILE_TYPES = [
...FILE_MIMES[UploadType.Image],
...FILE_MIMES[UploadType.Audio],
];
export const IMAGE_MIME_TYPES = FILE_MIMES.image;