Jmix 2.1 File storage management

Hello,

in CUBA we had a file storage manager under Administration-External Files (sys$FileDescriptor.browse)
Do we have something similar with Jmix 2.1, or are we to make it by ourselves? Also are there any plans to have something like that within a few months, like Februray release?

Kind regards,
Mladen

Created an entity, added fileRef attribute, made a simple view, and set upload and download as per the documentation. Will suffice for now.

Hi Mladen,

Look at solution used be me FileDescriptor in Jmix 2.0 - #3 by florin.tanasa
, maybe is what you need, also I added the code to get filename, extension and the size of file uploaded https://github.com/florintanasa/genedatabank/blob/master/src/main/java/com/genebank/genedatabank/view/sysfile/SysFileDetailView.java . The date used in createDate field from entity is the date used by users when they know/or not when the file was created/finalized, is not the same with createdDate from audit, when the file was uploaded.

Dear Florin,

this is a really good example, thank you for helping the people.
I used something similar to your SysFileDetailView.java.

The difference is

        if (event.getReceiver() instanceof FileTemporaryStorageBuffer buffer) {
            UUID fileId = buffer.getFileData().getFileInfo().getId();
            File file = temporaryStorage.getFile(fileId);
            if (file != null) {
                Long size = file.length();
                FileRef fileRef = temporaryStorage.putFileIntoStorage(fileId, event.getFileName());

Just a remark for the readers, one needs to get the file size before .putFileIntoStorage otherwise size information does not exist anymore and returns 0 - it is temporary storage after all :slight_smile:

Kind regards,
Mladen

2 Likes