Upload component clarification

Hi there!

I’m trying to add an upload component to my project but I’m unsure what the lambda inside the addSucceededListener method requires, I tried looking at the API but it’s way beyond my current skill level.

I copied this code from the upload page (only changing the identifier of the component):

MultiFileMemoryBuffer buffer = new MultiFileMemoryBuffer();
Upload uploadBox = new Upload(buffer);

uploadBox.addSucceededListener(event -> {
  Component component =
          createComponent(event.getMIMEType(),
          event.getFileName(),
          buffer.getInputStream(event.getFileName()));
  showOutput(event.getFileName(), component, output);
});

My IDE doesn’t recognise what createComponent is, and furthermore I’m unsure how I can serially take the document and process it, could somebody clarify this for me please?

Many thanks,

Ahmet

Hello, sorry for the inconvenience. We are planning to improve the examples.
In the meanwhile, here is a code for [createComponent]
(https://github.com/vaadin/vaadin-upload-flow/blob/c6e8e7de394c7fc1682ef3c64943a2cd116dfedd/vaadin-upload-flow-demo/src/main/java/com/vaadin/flow/component/upload/demo/UploadView.java#L267-L305) used in the dmeo.

Awesome!

It took me a second to realise how to store the uploaded file but I managed it using IOUtils.copy from the Apache IO library.

Much appreciated!