Hello i need to open excel file with spring boot and add data in database , but i get this error : The constructor File(InputStream) is undefined
the controller :
@PostMapping("/upload")
public ResponseEntity<?> addRfp (@RequestParam("file") MultipartFile file) throws IOException, InvalidFormatException {
OPCPackage pkg = OPCPackage.open(new File(file.getInputStream()));
XSSFWorkbook wb = new XSSFWorkbook(pkg);
System.out.print(wb.getAllNames());
return null;
}
the front end partie :
state = {
file : null
}
handlFile(e){
let file = e.target.files[0]
this.setState({file : file})
}
handleUpload(e){
let file = this.state.file;
let formdata = new FormData()
formdata.append('file', file)
formdata.append("name","ELMANDOUR AMINE")
axios({
url :'http://localhost:8080/rfp/upload',
method :'POST',
data : formdata
}).then((res)=>{})
}
the form :
input type="file" className="form-control" id="file" name="file" onChange={(e)=>this.handlFile(e)} required/>
</div>
</div>
<button id="button" type="button" onClick={(e)=>this.handleUpload(e)}> <img src={add} id="add" alt="Ajouter Region" /> </button>
please what i should to do i need to open the file excel and add the data at my database but when i try to open the file i get error what i should to do please !