Loading image from output/input stream in user-avatar sample

Hello, is it possible to load a picture from output/input stream, not using the FileDescriptor implementation? This example is from user-avatar sample:

@Inject
private Image userImage;

@Override
protected void postInit() {
    super.postInit();

    FileDescriptor userImageFile = ((UserExt) getItem()).getImage();

    userImage.setSource(FileDescriptorResource.class).setFileDescriptor(userImageFile); // here I cannot find a proper source to use
    
}

Thanks!

Hello, @dop1010

You should use StreamResource (JavaDoc):

image.setSource(StreamResource.class).setStreamSupplier(() -> {
    return yourInputStream;
});

Regards,
Daniil.

1 Like

Please see this :slight_smile:

https://doc.cuba-platform.com/manual-6.8/gui_Image.html

Thank you, @tsarev!

It is working as expected.