Upload not working with Spring

Hi ,

I am trying to execute a simple upload test and I found that in Vaadin 10,11 and 12 Pre , Upload does not work in Spring Starter packs.If I execute the same code with Project Base starter packs, the test is successful. Please let me know how to resolve this limitation.

`

public MainView() {
    MemoryBuffer buffer = new MemoryBuffer();
    Upload upload = new Upload(buffer);
    upload.addStartedListener(e-> System.out.println("Started"));
    upload.addSucceededListener(e->System.out.println("Successful"));
    add(upload);
}

`

Hi,

I had the same kind of error in Vaadin 8, I don’t know if it’s the same but by default Spring boot block x-frame options.

You may have a javascript error: Refuse to display … in a frame because it set ‘X-Frame-Options’ to ‘DENY’.
You can enable it: (check spring boot configuration)
http.headers().frameOptions().sameOrigin();

If you don’t have javascript error then it’s something else.

No there was no java script error. I did the above testing on new Starter templates.

For me its working with <vaadin.version>10.0.6</vaadin.version> but isnt with <vaadin.version>10.0.7</vaadin.version>
No javascript error.

Changes since 10.0.6 :
Vaadin Upload (web component v4.0.1 from v4.0.0)
see [10.0.7 Including latest maintenance releases]
(https://github.com/vaadin/platform/releases/tag/10.0.7) and vaadin/vaadin-upload

Thanks Norbert. I changed the vaadin to earlier version and it worked. Do you know why only Spring Template has this issue, because Project Base Starter pack latest version is successful.

Yes, this is known issue being investigated, there is a lenghty discussion in ticket here https://github.com/vaadin/spring/issues/381

Try changing Buffer and Upload to class members.

public class MyView extends VerticalLayout {
   private MemoryBuffer _buffer;
   private Upload _upload;
   ...
   
   public MyView() {
   
	    _buffer = new MemoryBuffer();
        _upload = new Upload(_buffer);
        add(_upload);
		...   
   }

   ...
}

Tatu Lund:
Yes, this is known issue being investigated, there is a lenghty discussion in ticket here https://github.com/vaadin/spring/issues/381

Hello, do you know if any solution to the problem was found?

Hello, do you know if any solution to the problem was found?

It works with Spring Boot and <vaadin.version>12.0.3</vaadin.version> and spring.servlet.multipart.enabled = false (see [Upload is broken for V12+Spring, and V10+SpringMVC #381]
(https://github.com/vaadin/spring/issues/381)).

Norbert Pocze:

Hello, do you know if any solution to the problem was found?

It works with Spring Boot and <vaadin.version>12.0.3</vaadin.version> and spring.servlet.multipart.enabled = false (see [Upload is broken for V12+Spring, and V10+SpringMVC #381]
(https://github.com/vaadin/spring/issues/381)).

Muchas gracias Thank you