Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Broken images in vaadin version 7.6.3

slodev surslodev
7 years ago Mar 16, 2016 7:13pm
Max Schuster
7 years ago Mar 16, 2016 8:24pm

Hi slodevmyname,

I think you can't reuse the InputStream. Try storing the data as byte array in your DTO and return a fresh (ByteArray)InputSteam instance everytime StreamSource#getStream is called.

But this approach will hit your ram pretty hard, because you have to keep all images in the servers memory. Even if you don't need them.

I'd suggest that you create a custom StreamSource implementation that receives the image from the database every time StreamSource#getStream is called. Because you only need the image data if the clientbrowser asks for it. And this way the image data can be garbagecollected if it's not needed anymore.

slodev surslodev
7 years ago Mar 16, 2016 9:30pm