{"record":{"id":"efc872efc2a71b06","repo":"BookStackApp/BookStack","slug":"not-an-image-file","errorCode":null,"errorMessage":"Not an image file","messagePattern":"Not an image file","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"resources/js/wysiwyg/utils/images.ts","lineNumber":34,"sourceCode":"    }, 'gallery');\n}\n\nexport function $createLinkedImageNodeFromImageData(image: EditorImageData): LinkNode {\n    const url = image.thumbs?.display || image.url;\n    const linkNode = $createLinkNode(url, {target: '_blank'});\n    const imageNode = $createImageNode(url, {\n        alt: image.name\n    });\n    linkNode.append(imageNode);\n    return linkNode;\n}\n\n/**\n * Upload an image file to the server\n */\nexport async function uploadImageFile(file: File, pageId: string): Promise<EditorImageData> {\n    if (file === null || file.type.indexOf('image') !== 0) {\n        throw new Error('Not an image file');\n    }\n\n    const remoteFilename = file.name || `image-${Date.now()}.png`;\n    const formData = new FormData();\n    formData.append('file', file, remoteFilename);\n    formData.append('uploaded_to', pageId);\n\n    const resp = await window.$http.post('/images/gallery', formData);\n    return resp.data as EditorImageData;\n}","sourceCodeStart":16,"sourceCodeEnd":44,"githubUrl":"https://github.com/BookStackApp/BookStack/blob/18f8469a1c72f8cc8497e9372635e6dea5028071/resources/js/wysiwyg/utils/images.ts#L16-L44","documentation":"Guard in uploadImageFile rejecting a File that is null or whose MIME type does not start with 'image', meaning a non-image (or unknown-type) file was passed to the image upload path. Input at fault: the dropped/pasted file with a non-image type.","triggerScenarios":"Thrown at resources/js/wysiwyg/utils/images.ts:34 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Only pass files with an image/* MIME type to uploadImageFile","Show the user a file-type error before invoking upload","Check browser-provided file.type; some files may report empty type and need extension fallback"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"18f8469a1c72f8cc8497e9372635e6dea5028071","analyzedAt":"2026-09-02T19:49:33.068Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}