As of Weave version 2.6.8, if a database data definition contains a Blob (or another binary type) column you can create a “blob” configuration for that column, this will expose that columns values via a URL, which can then be referenced in a data definition (or elsewhere) to allow the display of the content.
The table that the blob configuration references must have at least two columns, one containing a unique key value, used to reference the row to display the content from, and another containing the content to display. Additionally, if the content type is not the same for every row then you can also include a content type column that contains the mime type that will be used when sending the content to the user.
blob
Properties
Name | Type | Required | Description |
---|---|---|---|
id | string | yes | The id to reference this configuration |
datasource | yes | A reference to the data source that contains the content | |
table | string | yes | The name of the table that provides the content |
key | string | yes | The name of the column in the table that contains the unique key value |
column | string | yes | The name of the column in the table that contains the content |
contenttype | string | no | The mime type of the content that the column contains |
contenttypecolumn | string | no | The name of the column in the table that contains the mime type |
acl | ref urn:com.cohga.server.acl#1.0:acl | no | An ACL to apply to the content |
Content
None
Notes
If neither
contenttype
orcontenttypecolumn
is provided then “application/octet-stream” will be used.The content is then exposed at /data/blob/<id>/<key>
clob
Properties
Name | Type | Required | Description |
---|---|---|---|
id | string | yes | The id to reference this configuration |
datasource | yes | reference to the data source that contains the content | |
table | string | yes | The name of the table that provides the content |
key | string | yes | The name of the column in the table that contains the unique key value |
column | string | yes | The name of the column in the table that contains the content |
contenttype | string | no | The mime type of the content that the column contains |
contenttypecolumn | string | no | The name of the column in the table that contains the mime type |
acl | ref urn:com.cohga.server.acl#1.0:acl | no | An ACL to apply to the content |
Content
None
Notes
If neither
contenttype
orcontenttypecolumn
is provided then “text/plain” will be used.The content is then exposed at /data/clob/<id>/<key>
Examples
Assuming a postgres table that contains JPEG images in the content column:
create table blob_test ( pid integer not null, content bytea not null ); create index blob_test_idx on blob_test(prupi);
<data:blob id="example" acl="private"> <datasource>postgres</datasource> <table>blob_test</table> <key>pid</key> <column>content</column> <contentType>image/jpg</contentType> </data:blob>
The images can then be references using the URL http://weave.hostname/weave/data/blob/example/1234 (assuming there is a row that has the value 1234 in the pid column)
For a data definition you could then reference the column in a parameter with something like:
<parameter type="url" name="image" label="Image" text="Show" column="{fn concat('data/blob/example/', pid)}"/>