Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | 11x 11x 11x 11x 7x 11x 16x 4x 2x | // Client-side mirror of flows-api/infrastructure/lambda/utils/fileUploadPolicy.js
// — keep the two in sync. This is a UX convenience (immediate feedback before
// even attempting an upload), not a security boundary: the backend re-checks
// everything, and S3 itself enforces the size limit via the presigned POST
// policy (see uploads/presigned-url.js).
export const ALLOWED_FILE_MIME_TYPES = new Set([
'application/pdf',
'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.ms-powerpoint',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.oasis.opendocument.text',
'application/vnd.oasis.opendocument.spreadsheet',
'application/vnd.oasis.opendocument.presentation',
'application/rtf',
'text/plain',
'text/csv',
'application/zip',
'audio/mpeg',
'audio/wav',
'video/mp4',
'video/quicktime',
'image/jpeg',
'image/png',
'image/webp',
'image/gif'
])
export const ALLOWED_FILE_EXTENSIONS = new Set([
'pdf',
'doc',
'docx',
'xls',
'xlsx',
'ppt',
'pptx',
'odt',
'ods',
'odp',
'rtf',
'txt',
'csv',
'zip',
'mp3',
'wav',
'mp4',
'mov',
'jpg',
'jpeg',
'png',
'webp',
'gif'
])
export const MAX_FILE_SIZE_BYTES = 20 * 1024 * 1024 // 20MB
export function isAllowedFileUpload(fileName: string, fileType: string): boolean {
if (!ALLOWED_FILE_MIME_TYPES.has(fileType)) return false
const ext = (fileName.split('.').pop() || '').toLowerCase()
return ALLOWED_FILE_EXTENSIONS.has(ext)
}
export function formatFileSize(bytes: number): string {
if (bytes < 1024) return `${bytes} B`
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`
}
|