Hello everyone.
I’m considering to migrate an ETL application from CUBA to JMIX and I have this issue:
I need to upload an Excel spreadsheet, to open it and to launch data processes according to the data it contains.
In CUBA, I was using a FileUploadField and was getting a File object thanks to the FileUploadAPI. This file was then converted in FileInputStream, required to work with Apache POI.
As far as I’m seeing, this isn’t possible with JMIX anymore: it looks like we do need to use entities to store documents in a storage
-
it is not what I want: is there another solution that doesn’t impose the file to be stored ?
-
I had hard time to get a FileInputStream from the upload. I’m using the code below, but I don’t find it elegant. Is there any better option ?
FileRef fr = storedDc.getItem().getFile(); InputStream fi = fileStorage.openStream(fr); File file = new File("data.xlsx"); try (FileOutputStream outputStream = new FileOutputStream(file)) { int read; byte[] bytes = new byte[1024]; while((read = fi.read(bytes)) != -1) { outputStream.write(bytes,0, read); } } FileInputStream fis = new FileInputStream(file);
Thanks in advance. Have a nice day.
O.