abstract const classafBedSheet::Asset
sys::Obj afBedSheet::Asset
(Response Object) - An asset, such as File, which may be sent to the client.
An Asset instance wraps up all the information needed to send it to a client. The corresponding Asset ResponseProcessor sets the following HTTP headers:
Cache-ControlContent-LengthContent-TypeETagLast-Modified
Should the request headers allow, it may also respond with a 304 - Modified response. The Asset ResponseProcessor also correctly responds to HEAD requests.
When serving up your own files and images (say, from a database), it is recommended that your Route Handler return a custom Asset instance, from your own Asset subclass.
You may also wish to consider returning a ClientAsset.
- contentType
abstract MimeType? contentType()Returns the content type for the asset.
Returns
nullif asset doesn't exist.- etag
virtual Str? etag()The ETag uniquely identifies the asset and its version. The default implementation is a hash of the modified time and the asset size.
Returns
nullif asset doesn't exist- exists
virtual Bool exists()Returns
trueif the asset exists. (Or did at the time this class was created.)Returns
trueby default.- in
abstract InStream? in()Creates an
InStreamto read the contents of the asset. A new stream should be created each timein()is called.Returns
nullif asset doesn't exist, or can't be opened. (For example, if the asset is a recently deleted file resource).The caller is responsible for closing the stream. Note this can be as easy as calling
in.readAllBuf()orin.readAllStr().- makeFromFile
static new makeFromFile(File file)Creates a
Assetfor the given file.To create a
ClientAssetuse theFileHandlerorPodHandlerservice:fileHandler.fromServerFile(file)
- modified
abstract DateTime? modified()Get the modified time of the asset. Note that pod files have last modified info too!
Returns
nullif asset doesn't exist- size
abstract Int? size()The size of the asset in bytes.
Returns
nullif asset doesn't exist