Package com.vaadin.flow.server.streams
Class InputStreamDownloadHandler
java.lang.Object
com.vaadin.flow.server.streams.TransferProgressAwareHandler<DownloadEvent,InputStreamDownloadHandler>
com.vaadin.flow.server.streams.AbstractDownloadHandler<InputStreamDownloadHandler>
com.vaadin.flow.server.streams.InputStreamDownloadHandler
- All Implemented Interfaces:
DownloadHandler,ElementRequestHandler,Serializable
Download handler for serving an input stream for client download.
- Since:
- 24.8
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an input stream download handler for given event -> response function.InputStreamDownloadHandler(InputStreamDownloadCallback callback, String fileNameOverride) Create an input stream download handler for given event -> response function. -
Method Summary
Modifier and TypeMethodDescriptionOptional 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.voidhandleDownloadRequest(DownloadEvent downloadEvent) Method that is called when the client wants to download from the url stored for this specific handler registration.Methods inherited from class com.vaadin.flow.server.streams.AbstractDownloadHandler
getContentType, getTransferContext, inline, isInlineMethods inherited from class com.vaadin.flow.server.streams.TransferProgressAwareHandler
addTransferProgressListener, getListeners, notifyError, onProgress, onProgress, onProgress, onProgress, setTransferUI, uiAccess, whenComplete, whenComplete, whenStart, whenStartMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.server.streams.DownloadHandler
handleRequestMethods inherited from interface com.vaadin.flow.server.streams.ElementRequestHandler
getDisabledUpdateMode, isAllowInert
-
Constructor Details
-
InputStreamDownloadHandler
Create an input stream download handler for given event -> response function.- Parameters:
callback- serializable function for handling download
-
InputStreamDownloadHandler
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 downloadfileNameOverride- 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
Description copied from interface:DownloadHandlerMethod 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
Description copied from interface:ElementRequestHandlerOptional 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
nullfor "".
-