Class UploadEvent

java.lang.Object
com.vaadin.flow.server.streams.UploadEvent

public class UploadEvent extends Object
Class containing data on requested client upload to server.
Since:
24.8
  • Constructor Details

    • UploadEvent

      public UploadEvent(VaadinRequest request, VaadinResponse response, VaadinSession session, String fileName, long contentLength, String contentType, Element owningElement, jakarta.servlet.http.Part part)
      Create a new download event with required data.
      Parameters:
      request - current request
      response - current response to write response data to
      session - current session
      fileName - defined download file name
      contentLength - size of the upload
      contentType - content type string for upload
      owningElement - element owning this upload
      part - multipart part item, null for xhr upload
  • Method Details

    • getInputStream

      public InputStream getInputStream()
      Returns an input stream from which the request content can be read.
      Returns:
      the input stream from which the contents of the request can be read
      Throws:
      IllegalStateException - if the upload has been rejected
    • getRequest

      public VaadinRequest getRequest()
      Get VaadinRequest for download event.
      Returns:
      vaadin request
    • getResponse

      public VaadinResponse getResponse()
      Get VaadinResponse for download event.
      Returns:
      vaadin response
    • getSession

      public VaadinSession getSession()
      Get VaadinSession for download event.
      Returns:
      vaadin session
    • getFileName

      public String getFileName()
      Get the set file name for current upload.

      The file name will only be available for multipart uploads.

      Returns:
      file name
    • getContentType

      public String getContentType()
      Get the content type for the data to download.

      The content type will only be available for multipart uploads.

      Returns:
      set content type
    • getFileSize

      public long getFileSize()
      Get the content type for the data to download.
      Returns:
      set content type
    • getOwningComponent

      public Component getOwningComponent()
      Get owner Component for this event.
      Returns:
      owning component or null in none defined
    • getOwningElement

      public Element getOwningElement()
      Get the owning element for the upload related to this event.
      Returns:
      owning element
    • getUI

      public UI getUI()
      Return the UI for this upload event.
      Returns:
      UI for upload event
    • reject

      public void reject()
      Rejects this upload with a default message.

      When called, the file will not be processed (or will be cleaned up if already processed) and the rejection will be communicated to the client. The default rejection message "File rejected" will be used.

      See Also:
    • reject

      public void reject(String message)
      Rejects this upload with a custom message.

      When called, the file will not be processed (or will be cleaned up if already processed) and the rejection will be communicated to the client with the provided message.

      Parameters:
      message - the rejection message to send to the client
    • isRejected

      public boolean isRejected()
      Checks whether this upload has been rejected.
      Returns:
      true if the upload has been rejected, false otherwise
    • getRejectionMessage

      public String getRejectionMessage()
      Gets the rejection message if this upload has been rejected.
      Returns:
      the rejection message, or null if not rejected