Download action on FileDescriptor table

Hi cuba-platform developers,

Can you add download action on the table which it’s entities is FileDescriptor?
Default, I see the platform already has Create action to open upload window, Add action and Remove action.
An action to download those files is appreciated.

Thanks.

Hi,

The Administration > External Files screen provided by the platform contains the Download action. If you create your own screen for files, you have to add such action yourself. It’s very easy, something like this:

@Inject
private ExportDisplay exportDisplay;

@Inject
private Table<FileDescriptor> table;

public void download() {
    if (!table.getSelected().isEmpty()) {
        FileDescriptor fileDescriptor = table.getSelected().iterator().next();
        exportDisplay.show(fileDescriptor, ExportFormat.OCTET_STREAM);
    }
}
1 Like