Line data Source code
1 : import { t } from '@/i18n'
2 : import { useToast } from '@/components/ui/toast/toastStore'
3 :
4 : export const MAX_IMAGE_SIZE_MB = 10
5 : export const MAX_VIDEO_SIZE_MB = 50
6 :
7 0 : export function isFileTooLarge(file: File, maxSizeMB: number): boolean {
8 0 : const fileSizeMB = file.size / 1024 / 1024
9 0 : if (fileSizeMB <= maxSizeMB) return false
10 :
11 0 : useToast().error(t('g.error'), {
12 : description: t('toastMessages.fileTooLarge', {
13 : size: fileSizeMB.toFixed(1),
14 : maxSize: maxSizeMB
15 : })
16 : })
17 0 : return true
18 : }
|