MCPcopy Create free account
hub / github.com/R44VC0RP/opencode.cafe / handleFileUpload

Function handleFileUpload

app/submit/page.tsx:273–297  ·  view source on GitHub ↗
(e: React.ChangeEvent<HTMLInputElement>)

Source from the content-addressed store, hash-verified

271 }
272
273 const handleFileUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
274 const file = e.target.files?.[0]
275 if (!file) return
276
277 if (!file.name.endsWith(".json")) {
278 setJsonError("Please upload a .json file")
279 return
280 }
281
282 const reader = new FileReader()
283 reader.onload = (event) => {
284 const content = event.target?.result as string
285 setJsonInput(content)
286 parseAndApplyJson(content)
287 }
288 reader.onerror = () => {
289 setJsonError("Failed to read file")
290 }
291 reader.readAsText(file)
292
293 // Reset file input
294 if (fileInputRef.current) {
295 fileInputRef.current.value = ""
296 }
297 }
298
299 const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
300 e.preventDefault()

Callers

nothing calls this directly

Calls 1

parseAndApplyJsonFunction · 0.85

Tested by

no test coverage detected