Load images that are being generated during runtime

I am using Vaadin 14 with Spring Boot.

I have some images in src/main/resources/META-INF/resources/images/ that I can sucessfully display with Image image = new Image("images/image.png", "alt image text"); . I found out the path by trial and error.

When I generate new images in the same directory at runtime, I cannot access them unless I rebuild everything with mvn. I guess this is because the old images are originally available via the .war file and if I don’t regenerate that, new images are unavailable.

Two questions:

  1. Where is the path for the resources directory defined? Is this only valid for Vaadin or does Spring use the same? How are the resource paths for both related?
  2. How can I use new Image(...) to access images that are being generated during runtime without restarting mvn? Does Vaadin provide a way for that or do I have to use static Spring resources? If so, how do I tell Vaadins Image to use a Spring resource path?

You can crate your own resources. One way to do is to extend com.vaadin.flow.server.StreamResource.

Thanks for the tip, I found a way to make it work with StreamResource :slight_smile:

Nice to hear that you found a solution.