In the Domain Model you can define BLOB attributes. This attributes are objectified using an instance of a particular object implementing the RTXBLOBData interface. This type of object permits to access some properties of the wrapped BLOB:
- Name: the file name.
- Length: the file size in bytes.
- Extension: the file extension.
You can use the following data unit template to see BLOB information.
[% def file = unit.selectSingleNode("layout:Attribute[@name='file']") %]
upload path: ${<wr:UnitId/>.data.[%= getFieldName(file)%]}
name: ${<wr:UnitId/>.data.[%= getFieldName(file)%].name}
length: ${<wr:UnitId/>.data.[%= getFieldName(file)%].length}
extension: ${<wr:UnitId/>.data.[%= getFieldName(file)%].extension}
In the Web page you will see something like:
upload path: /upload/ent1/1/test.pdf
name: test.pdf
length: 2000
extension: pdf
The following code according to the Storage Type:
${<wr:UnitId/>.data.[%= getFieldName(file)%]}
represents
- The path of the file stored on the file system under the Web Application "upload" folder, if the BLOB Attribute is stored on the file system.
- A query string describing how to retrieve the BLOB binary data, if the BLOB Attribute is stored on the database.
A working example
For example if you want to render an image into the HTML page you can use one of the following templates depending on the chosen Storage Type
- BLOB stored on file system:
<a href="${<wr:UnitId/>.data.[%= getFieldName(file)%]}">
<c:out value="${<wr:UnitId/>.data.[%= getFieldName(file)%].name}"/>
</a>
- BLOB stored on the database:
<a href="<webratio:BLOB value="${<wr:UnitId/>.data.[%= getFieldName(file)%]}"/>">
<c:out value="${<wr:UnitId/>.data.[%= getFieldName(file)%].name}"/>
</a>