Writes raw bytes to the response under a caller-chosen content type, from either a byte array or an input stream. Created via ViewsBuilder.binaryView(...) from server-side JS and returned from a controller as the view for a request. The stream form is streamed to the response and the stream is closed afterwards, so it can only be rendered once; the byte array form is written in a single call and so holds the whole payload in memory. Any byte range on the request is ignored - the full content is always written.
Group: Views
Implements: View
Properties
| Property | Returns | Description |
|---|---|---|
| contentType | String | The content type supplied at construction, sent as the response's content type. |
| description | String | Short, user-facing label for this view, always "Binary data". |
Methods
getDescription()
Returns: String
Short, user-facing label for this view, always "Binary data".
render(CommonResource page, OutputStream out, Range range, Map<String,String> params, String contentType)
Returns: void
Writes the view's bytes to the response. A byte array is written in one call; an input stream is copied to the response and then closed, with a warning logged if closing it fails.
| Parameter | Description |
|---|---|
page | the resource the view is being rendered for, not used by this view |
out | the stream the bytes are written to |
range | not used by this view; the full content is always written |
params | request parameters, not used by this view |
contentType | not used by this view; getContentType() supplies the response content type |
getContentType()
Returns: String
The content type supplied at construction, sent as the response's content type.