Class InputStreamDownloadHandler

All Implemented Interfaces:
DownloadHandler, ElementRequestHandler, Serializable

public class InputStreamDownloadHandler extends AbstractDownloadHandler<InputStreamDownloadHandler>
Download handler for serving an input stream for client download.
Since:
24.8
See Also:
  • Constructor Details

    • InputStreamDownloadHandler

      public InputStreamDownloadHandler(InputStreamDownloadCallback callback)
      Create an input stream download handler for given event -> response function.
      Parameters:
      callback - serializable function for handling download
    • InputStreamDownloadHandler

      public InputStreamDownloadHandler(InputStreamDownloadCallback callback, String fileNameOverride)
      Create an input stream download handler for given event -> response function.

      The downloaded file fileNameOverride and download URL postfix will be set to fileNameOverride.

      Parameters:
      callback - serializable function for handling download
      fileNameOverride - used as a downloaded file name as a download request URL postfix, e.g. /VAADIN/dynamic/resource/0/5298ee8b-9686-4a5a-ae1d-b38c62767d6a/my-file.txt
  • Method Details

    • handleDownloadRequest

      public void handleDownloadRequest(DownloadEvent downloadEvent) throws IOException
      Description copied from interface: DownloadHandler
      Method that is called when the client wants to download from the url stored for this specific handler registration.
      Parameters:
      downloadEvent - download event containing the necessary data for writing the response
      Throws:
      IOException - if an IO error occurred during download
    • getUrlPostfix

      public String getUrlPostfix()
      Description copied from interface: ElementRequestHandler
      Optional URL postfix allows appending an application-controlled string, e.g. the logical name of the target file, to the end of the otherwise random-looking download URL. If defined, requests that would otherwise be routable are still rejected if the postfix is missing or invalid. Postfix changes the last segment in the resource url.
      Returns:
      String optional URL postfix, or null for "".