com.vaadin.flow.server.communication.

Class StreamReceiverHandler

    • Field Detail

      • DEFAULT_STREAMING_PROGRESS_EVENT_INTERVAL_MS

        public static final int DEFAULT_STREAMING_PROGRESS_EVENT_INTERVAL_MS

        See Also:

        Constant Field Values

    • Constructor Detail

      • StreamReceiverHandler

        public StreamReceiverHandler()
    • Method Detail

      • handleRequest

        public void handleRequest(VaadinSession session,
                                  VaadinRequest request,
                                  VaadinResponse response,
                                  StreamReceiver streamReceiver,
                                  String uiId,
                                  String securityKey)
                           throws IOException

        Handle reception of incoming stream from the client.

        Parameters:

        session - The session for the request

        request - The request to handle

        response - The response object to which a response can be written.

        streamReceiver - the receiver containing the destination stream variable

        uiId - id of the targeted ui

        securityKey - security from the request that should match registered stream receiver id

        Throws:

        IOException - if an IO error occurred

      • doHandleMultipartFileUpload

        protected void doHandleMultipartFileUpload(VaadinSession session,
                                                   VaadinRequest request,
                                                   VaadinResponse response,
                                                   StreamReceiver streamReceiver,
                                                   StateNode owner)
                                            throws IOException

        Streams content from a multipart request to given StreamVariable.

        This method takes care of locking the session as needed and does not assume the caller has locked the session. This allows the session to be locked only when needed and not when handling the upload data.

        Parameters:

        session - The session containing the stream variable

        request - The upload request

        response - The upload response

        streamReceiver - the receiver containing the destination stream variable

        owner - The owner of the stream

        Throws:

        IOException - If there is a problem reading the request or writing the response

      • doHandleXhrFilePost

        protected void doHandleXhrFilePost(VaadinSession session,
                                           VaadinRequest request,
                                           VaadinResponse response,
                                           StreamReceiver streamReceiver,
                                           StateNode owner,
                                           long contentLength)
                                    throws IOException

        Used to stream plain file post (aka XHR2.post(File))

        This method takes care of locking the session as needed and does not assume the caller has locked the session. This allows the session to be locked only when needed and not when handling the upload data.

        Parameters:

        session - The session containing the stream variable

        request - The upload request

        response - The upload response

        streamReceiver - the receiver containing the destination stream variable

        owner - The owner of the stream

        contentLength - The length of the request content

        Throws:

        IOException - If there is a problem reading the request or writing the response

      • getProgressEventInterval

        protected int getProgressEventInterval()

        To prevent event storming, streaming progress events are sent in this interval rather than every time the buffer is filled. This fixes #13155. To adjust this value override the method, and register your own handler in VaadinService.createRequestHandlers(). The default is 500ms, and setting it to 0 effectively restores the old behavior.

        Returns:

        the minimum interval to be used for streaming progress events

      • getContentLength

        protected long getContentLength(VaadinRequest request)

        The request.getContentLength() is limited to "int" by the Servlet specification. To support larger file uploads manually evaluate the Content-Length header which can contain long values.

      • isMultipartUpload

        protected boolean isMultipartUpload(VaadinRequest request)
      • getItemIterator

        protected org.apache.commons.fileupload.FileItemIterator getItemIterator(VaadinRequest request)
                                                                          throws org.apache.commons.fileupload.FileUploadException,
                                                                                 IOException

        Throws:

        org.apache.commons.fileupload.FileUploadException

        IOException