public class FileResource extends Object implements ConnectorResource
FileResources
are files or directories on local filesystem. The
files and directories are served through URI:s to the client terminal and
thus must be registered to an URI context before they can be used. The
resource is automatically registered to the application when it is created.CONNECTOR_PATH
Constructor and Description |
---|
FileResource(File sourceFile)
Creates a new file resource for providing given file for client
terminals.
|
Modifier and Type | Method and Description |
---|---|
int |
getBufferSize()
Gets the size of the download buffer used for this resource.
|
long |
getCacheTime()
Gets the length of cache expiration time.
|
String |
getFilename()
Gets the virtual filename for this resource.
|
String |
getMIMEType()
Gets the MIME type of the resource.
|
File |
getSourceFile()
Gets the source file.
|
DownloadStream |
getStream()
Gets resource as stream.
|
void |
setBufferSize(int bufferSize)
Sets the size of the download buffer used for this resource.
|
void |
setCacheTime(long cacheTime)
Sets the length of cache expiration time.
|
public FileResource(File sourceFile)
sourceFile
- the file that should be served.public DownloadStream getStream()
ConnectorResource
Note that this method is called while the session is locked to prevent
race conditions but the methods in the returned DownloadStream
are assumed to be unrelated to the VaadinSession and are called without
holding session locks (to prevent locking the session during long file
downloads).
getStream
in interface ConnectorResource
public File getSourceFile()
public String getFilename()
ConnectorResource
getFilename
in interface ConnectorResource
public String getMIMEType()
Resource
getMIMEType
in interface Resource
public long getCacheTime()
DownloadStream.DEFAULT_CACHETIME
.public void setCacheTime(long cacheTime)
cacheTime
- the cache time in milliseconds.public int getBufferSize()
If the buffer size is 0, the buffer size is decided by the terminal adapter. The default value is 0.
public void setBufferSize(int bufferSize)
bufferSize
- the size of the buffer in bytes.Copyright © 2019 Vaadin Ltd. All rights reserved.