How to avoid restarting the application each time a user uploads an image to ensure it displays on the homepage dynamically?

Hi everyone,

I’m encountering a problem with my Vaadin-based app. Every time a user uploads an image, I need to restart the application to get the image to display correctly on the homepage. Without a restart, only the alt text of the image is rendered.

My images are saved in /resources/images/**. I’ve tried configuring it with the following code:

public class StaticResourceConfiguration implements WebMvcConfigurer {
   // ...

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/images/**")
                .addResourceLocations("file:images/");
    }
}

Has anyone faced a similar issue or has any ideas on how to resolve this? Any help would be greatly appreciated!

Thanks in advance!

You can’t write in your resource folder at runtime (no Vaadin limitation!). Store it in a database, filesystem or content delivery / management system.

4 Likes