MCPcopy Index your code
hub / github.com/deepnote/deepnote / validateFileSize

Function validateFileSize

packages/cli/src/utils/import-client.ts:112–130  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

110 * @throws ImportError if the file exceeds the size limit
111 */
112export async function validateFileSize(filePath: string): Promise<number> {
113 const stats = await fs.stat(filePath)
114
115 if (stats.size <= 0) {
116 throw new ImportError('File is empty', 400)
117 }
118
119 if (stats.size > MAX_FILE_SIZE) {
120 const sizeMB = Math.round(MAX_FILE_SIZE / (1024 * 1024))
121 throw new ImportError(`File exceeds ${sizeMB}MB limit`, 413)
122 }
123
124 const fileName = basename(filePath)
125 if (fileName.length > 255) {
126 throw new ImportError('File name is too long (max 255 characters)', 400)
127 }
128
129 return stats.size
130}
131
132/**
133 * Custom error class for import-related errors.

Callers 2

openDeepnoteFileInCloudFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected