BLOB database fields are particular columns dedicated to store large binary data. You can use them to store binary files such as images, pdf document, AutoCAD files or, also, plain text data.
While, in WebGUI, there is a Wobject to show database records named SQLReport, there is no way to get data stored in BLOB columns. If you try to use SQLReport to show these kind of data, it will print out the ascii representation of this data.
![]() |
![]() |
|
Without BlobViewer | With BlobViewer |
This Wobject solves this problem and let you output correct records
BlobViewer is a W(eb)object for WebGUI (http://www.plainblack.com/webgui), one of the most popular open source content management systems (CMS). Currently supports WebGUI release 5.5, 6.0, 6.1 and 6.2 under Linux. The only database tested is MySQL.
Take a look at docs/BlobViewer/install.txt file for detailed installation instructions.
Let's show how to use BlobViewer with an example.
Create a table with a blob field such as this:
CREATE TABLE test_upload (
id int(11) NOT NULL auto_increment,
file_upload mediumblob NOT NULL,
nome varchar(255) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM
Insert some GIF image in the Blob fields. To do this you can use a mysql command line, a web tools like phpMyAdmin or directly inside WebGUI with SQLEdit Wobject.
Now we wish to show images in a page.
Add or select a page and add a "Blob Viewer.
Enter the SQL query to get BLOB data. You can use here macros to make dinamic query but the BLOB field must be the first element returned by query. For the table in the example you can enter something like this:
select file_upload from test_upload where id = ^FormParam(id);
so you must give a parameter id via query string or POST headers to have the correct image.
You must select also the Content-type of the binary data. To use "automatically detect" you must have File::MMagic module. You can download it here or via your CPAN module
perl -MCPAN -e 'install File::MMagic'.
Remember this is an optional module but if you don't install it, you must choose correct mime-type for your BLOB binary data a priori. If you use "Automatically detected" without File::MMagic module, " application/octet-stream will be used.
However, if mime type is not present in the list, you can select "Other" item and specify mime type value in the next text form field.
When you save, you will have an IFRAME with an error. Of course, because, we haven't still give "id" parameter. If we give correct parameter (http://....../page?id=1), we'll have the image into the IFRAME:
We have use IFRAME to have maximum flexibility with all documents. This is the same example with a PDF document (we must change content type setting if we don't have autodetect functionality)
however you can create you own template that fits your data. As an example, we give another template to get inline image. In the layout settings of your Wobject, select the "Image inline" template to have a normale image into an IMG tag.
All this example, are inline output, in the default WebGUI html page. For this example or, better, for binary data that cannot be view but only downloaded there is the possibility to get directly the outline version. The link is the one available in the string "whole window" in the IFRAME template and is composed by the WobjectId, the func value "outline" and all other parameter required, as an example, to give a link to download the PDF document above (or, in some browser, to show it in the whole window) must be:
http://....../page?wid=xx&func=outline&id=1