MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / validateImageFileSize

Function validateImageFileSize

apps/web/src/hooks/useImageUpload.ts:67–76  ·  view source on GitHub ↗
(
  file: File,
  maxSizeBytes: number,
  label = 'File'
)

Source from the content-addressed store, hash-verified

65 maxSizeBytes: number,
66 label = 'File'
67): string | null {
68 if (file.size > maxSizeBytes) {
69 return `${label} too large: ${formatFileSize(file.size)}. Maximum: ${formatFileSize(maxSizeBytes)}`;
70 }
71 return null;
72}
73
74function validateImageFileType(file: File, allowedTypes: readonly string[]): string | null {
75 if (!isAllowedImageType(file.type, allowedTypes)) {
76 return `Invalid file type: ${file.type}. Allowed: ${allowedTypes.join(', ')}`;
77 }
78 return null;
79}

Callers 3

preprocessImageFileFunction · 0.85

Calls 1

formatFileSizeFunction · 0.70

Tested by

no test coverage detected