now in vaadin StreamResource is depreciated, how can i show pdf stored in filestorage in iframe. My present code is-
if (event.getItem() != null) {
FileStorage fileStorage = fileStorageLocator.getDefault();
FileRef document = event.getItem().getFile();
if (document == null) {
return;
}
try (InputStream inputStream = fileStorage.openStream(document)) {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(inputStream.readAllBytes());
StreamResource resource = new StreamResource(document.getFileName(), () -> byteArrayInputStream);
StreamRegistration registration = VaadinSession.getCurrent().getResourceRegistry().registerResource(resource);
frame1.setSrc(registration.getResourceUri().toString());
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
gorelov
(Gleb Gorelov)
November 14, 2025, 8:34am
2
Hi,
According to the StreamResource JavaDoc, the com.vaadin.flow.server.streams.DownloadHandler should be used instead. Take a look at the Vaadin doc for more details.
Regards,
Gleb
ckwan
(Choon Kit Wan)
November 15, 2025, 5:43am
3
Hi Gleb,
How about MemoryBuffer?
Use com.vaadin.flow.server.streams.UploadHandler instead?
Regards,
CK
gorelov
(Gleb Gorelov)
November 17, 2025, 7:03am
5
Looks like it. Take a look at the Vaadin doc for more details.
Regards,
Gleb
f.zehnder
(F Zehnder)
January 15, 2026, 7:54am
7
hi @gorelov
I want to replace StreamResource with DownloadHandler to display an image in a component and the AI tells me
https://ai-assistant.jmix.io/chatbot?chatSessionId=019bc04c-f3e6-7e8b-b65d-3dffb3e09773
Given what’s in the official Jmix 2.x docs/samples:
There is no provided factory or example like
DownloadHandler.fromStream(() -> fileStorage.openStream(fileRef), ...) in Jmix samples.
Possible to adapt the documentation ( for example 6. Working with Images :: Jmix Documentation ) ?
Thank you
Felix
gorelov
(Gleb Gorelov)
January 15, 2026, 9:45am
8
Hi @f.zehnder ,
The linked doc section (Displaying Image in Form ) doesn’t contain a sample code that uses StreamResource. Probably the link refers to the incorrect section. Anyway, I’ve created a github issue - Update sample code that uses deprecated StreamResource to use DownloadHandler · Issue #1096 · jmix-framework/jmix-docs · GitHub .
Indeed, DownloadHandler doesn’t provide the fromStream factory method, instead, it provides fromInputStream.
Regards,
Gleb
f.zehnder
(F Zehnder)
January 15, 2026, 5:59pm
9
Hi @gorelov
Do I missinterpret something ?
Regards
Felix
gorelov
(Gleb Gorelov)
January 15, 2026, 6:22pm
10
The link you provided refers to the Displaying Image in Form section that doesn’t contain StreamResource usage. The code you’ve attached is from the Displaying Image in Data Grid section. Anyway, as I said, I’ve created a github issue.
Regards,
Gleb