com.vaadin.flow.server.
Class StreamResource
All Implemented Interfaces:
Represents dynamically generated data.
Resource URI registration is automatically handled by components that
explicitly support stream resources and by
Element.setAttribute(String, AbstractStreamResource)
. In other cases,
the resource must manually be registered using
StreamResourceRegistry.registerResource(AbstractStreamResource)
to
get a URI from which the browser can load the contents of the resource.
Since:
1.0
Author:
Vaadin Ltd
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionStreamResource
(String name, InputStreamFactory factory) Deprecated, for removal: This API element is subject to removal in a future version.
Creates
StreamResource
instance using mandatory parametersname
as a resource file name and input streamfactory
as a factory for data.StreamResource
(String name, StreamResourceWriter writer) Deprecated, for removal: This API element is subject to removal in a future version.
Creates
StreamResource
instance using mandatory parametersname
as a resource file name and output streamwriter
as a data producer. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated, for removal: This API element is subject to removal in a future version.
Gets the resolver which is used to lookup the content type of the resource.
Deprecated, for removal: This API element is subject to removal in a future version.
Gets the value for header
name
set for the resource.Deprecated, for removal: This API element is subject to removal in a future version.
Gets the additionally configured headers for the resource.
getName()
Deprecated, for removal: This API element is subject to removal in a future version.
Get the resource name.
Deprecated, for removal: This API element is subject to removal in a future version.
Returns the stream resource writer.
setContentType
(String contentType) Deprecated, for removal: This API element is subject to removal in a future version.
Set content type for the resource.
setContentTypeResolver
(ContentTypeResolver resolver) Deprecated, for removal: This API element is subject to removal in a future version.
Sets the resolver which is used to lookup the content type of the resource.
Deprecated, for removal: This API element is subject to removal in a future version.
Sets the value of a generic response header.
Methods inherited from class com.vaadin.flow.server.AbstractStreamResource
getCacheTime, getId, setCacheTime
-
Constructor Details
-
StreamResource
Deprecated, for removal: This API element is subject to removal in a future version.Creates
StreamResource
instance using mandatory parametersname
as a resource file name and output streamwriter
as a data producer.writer
should write data in the output stream provided as an argument to itsStreamResourceWriter.accept(OutputStream, VaadinSession)
method.name
parameter value will be used in URI (generated when resource is registered) in a way that thename
is the last segment of the path. So this is synthetic file name (not real one).Parameters:
name
- resource file name. May not be null.writer
- data output stream consumer -
StreamResource
Deprecated, for removal: This API element is subject to removal in a future version.Creates
StreamResource
instance using mandatory parametersname
as a resource file name and input streamfactory
as a factory for data.name
parameter value will be used in URI (generated when resource is registered) in a way that thename
is the last segment of the path. So this is synthetic file name (not real one).Parameters:
name
- resource file name. May not be null.factory
- data input stream factory. May not be null.
-
-
Method Details
-
getWriter
Deprecated, for removal: This API element is subject to removal in a future version.Returns the stream resource writer.
Writer writes data in the output stream provided as an argument to its
StreamResourceWriter.accept(OutputStream, VaadinSession)
method.Returns:
stream resource writer
-
setContentTypeResolver
Deprecated, for removal: This API element is subject to removal in a future version.Sets the resolver which is used to lookup the content type of the resource.
By default a resolver based on servletContext.getMimeType() is used.
Parameters:
resolver
- content type resolver, notnull
Returns:
this resource
-
setContentType
Deprecated, for removal: This API element is subject to removal in a future version.Set content type for the resource.
This is a shorthand for
setContentTypeResolver(ContentTypeResolver)
with resolver which always returnscontentType
Parameters:
contentType
- resource content type, notnull
Returns:
this resource
-
getContentTypeResolver
Deprecated, for removal: This API element is subject to removal in a future version.Gets the resolver which is used to lookup the content type of the resource.
Returns:
content type resolver
-
setHeader
Deprecated, for removal: This API element is subject to removal in a future version.Sets the value of a generic response header. If the header had already been set, the new value overwrites the previous one.
Parameters:
name
- a header namevalue
- value of the headerReturns:
this resource
-
getHeader
Deprecated, for removal: This API element is subject to removal in a future version.Gets the value for header
name
set for the resource.Parameters:
name
- name of header to get value forReturns:
an optional with header value, or an empty optional if it has not been set
-
getHeaders
Deprecated, for removal: This API element is subject to removal in a future version.Gets the additionally configured headers for the resource.
This method doesn't return headers which are set via explicit setters like
setContentType(String)
andAbstractStreamResource.setCacheTime(long)
.Returns:
a map of headers and their values
-
getName
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from class:
AbstractStreamResource
Get the resource name.
The value will be used in URI (generated when resource is registered) in a way that the
name
is the last segment of the path. So this is a synthetic name.Specified by:
getName
in classAbstractStreamResource
Returns:
resource name
-
DownloadHandler
instead