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

Function handleFileUpload

app/admin/import/page.tsx:145–168  ·  view source on GitHub ↗
(e: React.ChangeEvent<HTMLInputElement>)

Source from the content-addressed store, hash-verified

143 }
144
145 const handleFileUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
146 const file = e.target.files?.[0]
147 if (!file) return
148
149 if (!file.name.endsWith(".json")) {
150 setParseError("Please upload a .json file")
151 return
152 }
153
154 const reader = new FileReader()
155 reader.onload = (event) => {
156 const content = event.target?.result as string
157 setJsonInput(content)
158 parseJson(content)
159 }
160 reader.onerror = () => {
161 setParseError("Failed to read file")
162 }
163 reader.readAsText(file)
164
165 if (fileInputRef.current) {
166 fileInputRef.current.value = ""
167 }
168 }
169
170 const handleImport = async () => {
171 if (parsedExtensions.length === 0) return

Callers

nothing calls this directly

Calls 1

parseJsonFunction · 0.85

Tested by

no test coverage detected