Byte Array to FileDescriptor

I am probably just missing somethings here but and help would be appreciated.

I’m getting back from a a third party API call a response that includes a Base64 encoded string. I’ve decoded the data string to a byte array. But now I’m not sure how to save this byte array as a file descriptor. I know I can write that byte array to a file but then I’m not sure how to actually bundle that into a FileDescriptor to save to external storage.



The method can be used to save byte array to file storage.

private FileStorageService fileStorageService;
private Metadata metadata;
private Notifications notifications;
private TimeSource timeSource;
private DataManager dataManager;

public void onBtnClick(Button.ClickEvent event) {
    // Create a file descriptor assosiated with a file in a file storage
    FileDescriptor fileDescriptor = metadata.create(FileDescriptor.class);

    byte[] data = "test text".getBytes();

    try {
        fileStorageService.saveFile(fileDescriptor, data);
    } catch (FileStorageException e) {



What would be the maximum size allowed?

The size limitation would not be on CUBA’s side. It would be on S3’s side. The only thing being captured on CUBA’s side is the UUID of the FileDescriptor entity, the file type, and the date created. With those 3 things it can upload/retrieve pretty much any file to/from S3.

Additionally, the cuba.maxUploadSizeMb property can be used to specify the maximum file size (in megabytes) that can be uploaded using the FileUploadField and FileMultiUploadField components.


1 Like

i was wondering if there are any defined set of configurations that could place restrictions on max file size, but @gorelov recent response just made it clear.