Class UploadFileHandler

  • All Implemented Interfaces:
    com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.upload.Receiver, Serializable, FluentAttachNotifier<VUpload>, FluentComponent<VUpload>, FluentDetachNotifier<VUpload>, FluentHasSize<VUpload>, FluentHasStyle<VUpload>

    public class UploadFileHandler
    extends VUpload
    implements com.vaadin.flow.component.upload.Receiver
    An upload implementation that just pass the input stream (and name and mime type) of the uploaded file for developer to handle.

    Note, then FileHandler you pass in is not executed in the UI thread. If you want to modify the UI from it, by sure to use UI.access to handle locking properly.

    Note, all Upload features are not supported (but the lazy developer is not throwing exceptions on all those methods).

    Author:
    mstahv
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  UploadFileHandler.FileHandler  
      • Nested classes/interfaces inherited from class com.vaadin.flow.component.upload.GeneratedVaadinUpload

        com.vaadin.flow.component.upload.GeneratedVaadinUpload.FileRejectEvent<R extends com.vaadin.flow.component.upload.GeneratedVaadinUpload<R>>, com.vaadin.flow.component.upload.GeneratedVaadinUpload.FilesChangeEvent<R extends com.vaadin.flow.component.upload.GeneratedVaadinUpload<R>>, com.vaadin.flow.component.upload.GeneratedVaadinUpload.MaxFilesReachedChangeEvent<R extends com.vaadin.flow.component.upload.GeneratedVaadinUpload<R>>, com.vaadin.flow.component.upload.GeneratedVaadinUpload.UploadAbortEvent<R extends com.vaadin.flow.component.upload.GeneratedVaadinUpload<R>>, com.vaadin.flow.component.upload.GeneratedVaadinUpload.UploadBeforeEvent<R extends com.vaadin.flow.component.upload.GeneratedVaadinUpload<R>>, com.vaadin.flow.component.upload.GeneratedVaadinUpload.UploadErrorEvent<R extends com.vaadin.flow.component.upload.GeneratedVaadinUpload<R>>, com.vaadin.flow.component.upload.GeneratedVaadinUpload.UploadProgressEvent<R extends com.vaadin.flow.component.upload.GeneratedVaadinUpload<R>>, com.vaadin.flow.component.upload.GeneratedVaadinUpload.UploadRequestEvent<R extends com.vaadin.flow.component.upload.GeneratedVaadinUpload<R>>, com.vaadin.flow.component.upload.GeneratedVaadinUpload.UploadResponseEvent<R extends com.vaadin.flow.component.upload.GeneratedVaadinUpload<R>>, com.vaadin.flow.component.upload.GeneratedVaadinUpload.UploadRetryEvent<R extends com.vaadin.flow.component.upload.GeneratedVaadinUpload<R>>, com.vaadin.flow.component.upload.GeneratedVaadinUpload.UploadStartEvent<R extends com.vaadin.flow.component.upload.GeneratedVaadinUpload<R>>, com.vaadin.flow.component.upload.GeneratedVaadinUpload.UploadSuccessEvent<R extends com.vaadin.flow.component.upload.GeneratedVaadinUpload<R>>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      OutputStream receiveUpload​(String filename, String mimeType)  
      protected void writeResponce​(PipedInputStream in, String filename, String mimeType)
      By default just spans a new raw thread to get the input.
      • Methods inherited from class com.vaadin.flow.component.upload.Upload

        addAllFinishedListener, addFailedListener, addFileRejectedListener, addFinishedListener, addProgressListener, addStartedListener, addSucceededListener, fireUpdateProgress, getAcceptedFileTypes, getDropLabel, getDropLabelIcon, getI18n, getMaxFiles, getMaxFileSize, getReceiver, getUploadButton, interruptUpload, isAutoUpload, isDropAllowed, isUploading, setAcceptedFileTypes, setAutoUpload, setDropAllowed, setDropLabel, setDropLabelIcon, setI18n, setMaxFiles, setMaxFileSize, setReceiver, setUploadButton
      • Methods inherited from class com.vaadin.flow.component.upload.GeneratedVaadinUpload

        addFileRejectListener, addFilesChangeListener, addMaxFilesReachedChangeListener, addToAddButton, addToDropLabel, addToDropLabelIcon, addToFileList, addUploadAbortListener, addUploadBeforeListener, addUploadErrorListener, addUploadProgressListener, addUploadRequestListener, addUploadResponseListener, addUploadRetryListener, addUploadStartListener, addUploadSuccessListener, getAcceptString, getCaptureString, getFilesJsonArray, getFormDataNameString, getHeadersJsonObject, getI18nJsonObject, getMaxFilesDouble, getMaxFileSizeDouble, getMethodString, getTargetString, getTimeoutDouble, isMaxFilesReachedBoolean, isNoAutoBoolean, isNodropBoolean, isWithCredentialsBoolean, remove, removeAll, setAccept, setCapture, setFiles, setFormDataName, setHeaders, setI18n, setMaxFiles, setMaxFileSize, setMethod, setNoAuto, setNodrop, setTarget, setTimeout, setWithCredentials, uploadFiles
      • Methods inherited from class com.vaadin.flow.component.Component

        addListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
      • Methods inherited from interface com.vaadin.flow.component.AttachNotifier

        addAttachListener
      • Methods inherited from interface com.vaadin.flow.component.DetachNotifier

        addDetachListener
      • Methods inherited from interface com.vaadin.flow.component.HasElement

        getElement
      • Methods inherited from interface com.vaadin.flow.component.HasSize

        getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
      • Methods inherited from interface com.vaadin.flow.component.HasStyle

        addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
    • Method Detail

      • receiveUpload

        public OutputStream receiveUpload​(String filename,
                                          String mimeType)
        Specified by:
        receiveUpload in interface com.vaadin.flow.component.upload.Receiver
      • writeResponce

        protected void writeResponce​(PipedInputStream in,
                                     String filename,
                                     String mimeType)
        By default just spans a new raw thread to get the input. For strict Java EE fellows, this might not suite, so override and use executor service.
        Parameters:
        in - the input stream where file content can be handled
        filename - the file name on the senders machine
        mimeType - the mimeType interpreted from the file name