RdbHost delivers the results of a query as an XML, JSON or binary page; for most purposes, JSON is the preferred format, as it returns records and fields as structured data. If you prefer xml, that format will provide structured data as well.
If you want your data raw, your fields glued together without any structure, the binary format will provide that.
If the query succeeds, the data will be sent as follows: fields of a record are catenated into record blobs, and record blobs are catenated together into one blob to return. We expect that this will be most useful with queries that return exactly one field.
If the query fails, the error message is plain text, without any structure or markup.
The binary mode is requested with the format parameter. The passed value must start with 'binary', but can also include a content type, like 'format=binary:text/plain', separated by a ':'. If the value includes the content type, the server sends a 'Content-Type' header with that string. Otherwise, the Content-Type is 'application/octet-stream'.
As an alternative, you may provide the format as 'binary', and include another parameter 'contenttype' with the content type; so "format=binary&contenttype=image/gif" is equivalent to "format=binary:image/gif".
<img src="http://www.rdbhost.com/db/p0000000008? q=SELECT body FROM lookup.files WHERE path='/img/sidebar/austria-clouds.jpg'& format=binary:image/jpg" width=100 height=100>
Images and other resources can be retrieved through src or href attributes, without the need for client-side coding.
The query is not automatically whitelisted. Workarounds:
- Use Reader role, and appropriate SQL privileges.
- Manually enter the query into the white-list, either with RdbAdmin or a custom utility. This can be facilitated by using a server-side function ie: SELECT get_bin();
- Put the data into the lookup.files table, and use a simple href or src attribute to retrieve it.