Class InMemoryUploadHandler

java.lang.Object
com.vaadin.flow.server.streams.TransferProgressAwareHandler<com.vaadin.flow.server.streams.UploadEvent,InMemoryUploadHandler>
com.vaadin.flow.server.streams.AbstractUploadHandler<InMemoryUploadHandler>
io.jmix.flowui.component.upload.handler.InMemoryUploadHandler
All Implemented Interfaces:
com.vaadin.flow.server.streams.ElementRequestHandler, com.vaadin.flow.server.streams.UploadHandler, TransferProgressNotifier, SupportUploadSuccessHandler<byte[]>, Serializable

@Component("flowui_InMemoryUploadHandler") @Scope("prototype") public class InMemoryUploadHandler extends com.vaadin.flow.server.streams.AbstractUploadHandler<InMemoryUploadHandler> implements TransferProgressNotifier, SupportUploadSuccessHandler<byte[]>
Upload handler for storing the upload in-memory. Data is returned as a byte[] to the given successHandler.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.jmix.flowui.kit.component.upload.handler.SupportUploadSuccessHandler

    SupportUploadSuccessHandler.UploadSuccessContext<V>, SupportUploadSuccessHandler.UploadSuccessHandler<V>

    Nested classes/interfaces inherited from interface com.vaadin.flow.server.streams.UploadHandler

    com.vaadin.flow.server.streams.UploadHandler.MixedUploadResponse, com.vaadin.flow.server.streams.UploadHandler.RejectedFilesResponse
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    addTransferProgressListener(com.vaadin.flow.server.streams.TransferProgressListener listener)
     
    void
    handleUploadRequest(com.vaadin.flow.server.streams.UploadEvent event)
     
    protected byte @Nullable []
    readContent(com.vaadin.flow.server.streams.UploadEvent event)
    Runs the metadata and header validators and reads the whole upload into memory.
    void
    Sets a handler to be invoked upon the successful completion of an upload operation.

    Methods inherited from class com.vaadin.flow.server.streams.AbstractUploadHandler

    applyHeaderValidators, getTransferContext, hasValidators, runCompleteValidators, runMetadataValidators, validateComplete, validateHeader, validateMetadata, withValidator

    Methods inherited from class com.vaadin.flow.server.streams.TransferProgressAwareHandler

    getListeners, notifyError, onProgress, onProgress, onProgress, onProgress, setTransferUI, uiAccess, whenComplete, whenComplete, whenStart, whenStart

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.server.streams.ElementRequestHandler

    getDisabledUpdateMode, getUrlPostfix, isAllowInert

    Methods inherited from interface com.vaadin.flow.server.streams.UploadHandler

    getFileCountMax, getFileSizeMax, getRequestSizeMax, handleRequest, responseHandled
  • Field Details

  • Constructor Details

    • InMemoryUploadHandler

      public InMemoryUploadHandler()
  • Method Details

    • handleUploadRequest

      public void handleUploadRequest(com.vaadin.flow.server.streams.UploadEvent event) throws IOException
      Specified by:
      handleUploadRequest in interface com.vaadin.flow.server.streams.UploadHandler
      Throws:
      IOException
    • readContent

      protected byte @Nullable [] readContent(com.vaadin.flow.server.streams.UploadEvent event) throws IOException
      Runs the metadata and header validators and reads the whole upload into memory.
      Parameters:
      event - the upload being handled
      Returns:
      the uploaded data, or null if a validator rejected the upload before it was read
      Throws:
      IOException - if reading the upload or a validator fails
    • addTransferProgressListener

      public com.vaadin.flow.shared.Registration addTransferProgressListener(com.vaadin.flow.server.streams.TransferProgressListener listener)
      Specified by:
      addTransferProgressListener in interface TransferProgressNotifier
      Overrides:
      addTransferProgressListener in class com.vaadin.flow.server.streams.TransferProgressAwareHandler<com.vaadin.flow.server.streams.UploadEvent,InMemoryUploadHandler>
    • setUploadSuccessHandler

      public void setUploadSuccessHandler(@Nullable SupportUploadSuccessHandler.UploadSuccessHandler<byte[]> handler)
      Description copied from interface: SupportUploadSuccessHandler
      Sets a handler to be invoked upon the successful completion of an upload operation.

      If null is passed as the parameter, any previously set handler will be cleared.

      Specified by:
      setUploadSuccessHandler in interface SupportUploadSuccessHandler<byte[]>
      Parameters:
      handler - the handler to be executed on a successful upload; may be null to clear any existing handler