File upload example

I’m familiar with Vaadin 8 where the upload is received by a receiver class.

What’s the equivalent in Vaadin 10? The documentation states that a Servlet needs to be created to receive the file. While I understand what the servlet should do it’s not clear to me how to pass the “receive event” to the serverside UI i.e. to execute some kind of callback (in the same session) which in turn modifies the client.

Please point me in the right direction or provide an example.

Where did you read about a needing a servlet?

In the documentation

That documentation would be for when you’re creating a custom (non-Flow) backend for the <vaadin-upload> component. That could probably be stated somewhere more clearly.

Thanks for pointing that out.

How can I call uploadFiles on Upload component from java?
I can not also find how to reset Upload component. I mean to clear file list.
Can you please provide an example.

Why do you want to upload files from Java? You’re already on the server.

I want call the method uploadFiles. Client run application in browser. He wants select files, enter some data in form and only then, if data is correct, send all files together at once to server.

I see! As far as I can tell, that part of the Upload component’s API is not exposed to the Java side yet; you should go thumbs-up and comment this ticket:

You could probably call that particular function from Java via JavaScript with UI.getCurrent().getPage().executeJavaScript().


Or using the easier API: upload.getElement().callFunction("uploadFiles")

You’ve made my day, Artur.
Thanks a lot.