com.vaadin.flow.server.communication.
Class StreamReceiverHandler
- java.lang.Object
-
- com.vaadin.flow.server.communication.StreamReceiverHandler
-
All Implemented Interfaces:
public class StreamReceiverHandler extends Object implements Serializable
Handles
StreamReceiver
instances registered inVaadinSession
.Since:
1.0
Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
StreamReceiverHandler.UploadInterruptedException
An UploadInterruptedException will be thrown by an ongoing upload if
StreamVariable.isInterrupted()
returnstrue
.
-
Field Summary
Fields Modifier and Type Field and Description static int
DEFAULT_STREAMING_PROGRESS_EVENT_INTERVAL_MS
-
Constructor Summary
Constructors Constructor and Description StreamReceiverHandler()
-
Method Summary
All Methods Modifier and Type Method and Description protected void
doHandleMultipartFileUpload(VaadinSession session, VaadinRequest request, VaadinResponse response, StreamReceiver streamReceiver, StateNode owner)
Streams content from a multipart request to given StreamVariable.
protected void
doHandleXhrFilePost(VaadinSession session, VaadinRequest request, VaadinResponse response, StreamReceiver streamReceiver, StateNode owner, long contentLength)
Used to stream plain file post (aka XHR2.post(File))
protected long
getContentLength(VaadinRequest request)
The request.getContentLength() is limited to "int" by the Servlet specification.
protected org.apache.commons.fileupload.FileItemIterator
getItemIterator(VaadinRequest request)
protected Collection<Part>
getParts(VaadinRequest request)
protected int
getProgressEventInterval()
To prevent event storming, streaming progress events are sent in this interval rather than every time the buffer is filled.
void
handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response, StreamReceiver streamReceiver, String uiId, String securityKey)
Handle reception of incoming stream from the client.
protected boolean
isMultipartUpload(VaadinRequest request)
-
-
-
Field Detail
-
DEFAULT_STREAMING_PROGRESS_EVENT_INTERVAL_MS
public static final int DEFAULT_STREAMING_PROGRESS_EVENT_INTERVAL_MS
See Also:
-
-
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 requestrequest
- The request to handleresponse
- The response object to which a response can be written.streamReceiver
- the receiver containing the destination stream variableuiId
- id of the targeted uisecurityKey
- security from the request that should match registered stream receiver idThrows:
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 variablerequest
- The upload requestresponse
- The upload responsestreamReceiver
- the receiver containing the destination stream variableowner
- The owner of the streamThrows:
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 variablerequest
- The upload requestresponse
- The upload responsestreamReceiver
- the receiver containing the destination stream variableowner
- The owner of the streamcontentLength
- The length of the request contentThrows:
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)
-
getParts
protected Collection<Part> getParts(VaadinRequest request) throws Exception
Throws:
-
getItemIterator
protected org.apache.commons.fileupload.FileItemIterator getItemIterator(VaadinRequest request) throws org.apache.commons.fileupload.FileUploadException, IOException
Throws:
org.apache.commons.fileupload.FileUploadException
-
-