title: How can I receive the file contents in my Vaadin service?
body: <p>I want to add an upload button to my web application. In the HTML template, I added:</p>
  
  <pre><code>&lt;link rel="import" href="../../../bower_components/vaadin-upload/src/vaadin-upload.html"&gt;
  
  &lt;h2 id="header-Upload"&gt;Upload&lt;/h2&gt;
  &lt;vaadin-upload nodrop/&gt;
  </code></pre>
  
  <p>I now want to receive the stream in my backend Vaadin process. This stream can be then inserted in the database.</p>
  
  <p>The documentation on <a href="https://vaadin.com/components/vaadin-upload/html-examples/upload-basic-demos" rel="nofollow noreferrer">https://vaadin.com/components/vaadin-upload/html-examples/upload-basic-demos</a> doesn't provide this information.</p>
  
  <p>I believe I should somehow link a <code>StreamReceiver</code> to the <code>&lt;vaadin-upload&gt;</code> in question, but I am not sure how to do that.</p>
  
  <p>I am using Vaadin Flow (version 12).</p>
  
  <p><strong>Additional information</strong></p>
  
  <p>I tried the following:</p>
  
  <p>In HTML:</p>
  
  <pre><code>&lt;vaadin-upload id="upload" nodrop/&gt;
  </code></pre>
  
  <p>In Java:</p>
  
  <pre><code>public class MyView extends PolymerTemplate&lt;Model&gt; {
      private final MemoryBuffer buffer = new MemoryBuffer();
      @Id("upload")
      private final Upload       upload = new Upload(buffer);
  
      public MyView() {
          upload.addSucceededListener(event -&gt; {
              System.out.println(event.getFileName());
              System.out.println(buffer.getInputStream());
          });
      }
  }
  </code></pre>
  
  <p>When I upload a file, I get the following exception:</p>
  
  <pre><code>[qtp162821120-20] ERROR com.vaadin.flow.server.DefaultErrorHandler - 
  com.vaadin.flow.server.UploadException: Upload failed
      at com.vaadin.flow.server.communication.StreamReceiverHandler.streamToReceiver(StreamReceiverHandler.java:429)
  
  Caused by: java.lang.IllegalStateException: Upload cannot be performed without a receiver set
      at com.vaadin.flow.component.upload.Upload$DefaultStreamVariable.getOutputStream(Upload.java:581)
      at com.vaadin.flow.server.communication.StreamReceiverHandler.streamToReceiver(StreamReceiverHandler.java:358)
  </code></pre>