在 React dropzone 中,我收到一个带有File.preview属性的File对象,其值是一个blob:url。例如:File {preview: "blob:http://localhost:8080/52b6bad4-58f4-4ths-a2f5-4ee258ba864a"
有没有办法在客户端将其转换为JSON?这个文件不需要被存储在数据库中(转换后的JSON需要)。我尝试使用csvtojson,但它无法使用文件系统,因为它使用Node来支持它。如果可能的话,最好能在客户端上传后进行转换。欢迎任何建议。
<Dropzone
name={field.name}
onDrop={(acceptedFiles, rejectedFiles) => {
acceptedFiles.forEach(file => {
console.log(file)
let tempFile = file.preview
csv()
.fromSteam(tempFile) // this errors with fs.exists not a function as its not running serverside
.on('end_parsed',(jsonArrObj)=>{
console.log(jsonArrObj)
})
})
}}
>