Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: displaying Jpg BLOB in Web browser using PL/SQL

Re: displaying Jpg BLOB in Web browser using PL/SQL

From: Vladimir M. Zakharychev <bob_at_dpsp-yes.com>
Date: Tue, 18 Jun 2002 12:35:32 +0400
Message-ID: <aemrcm$nno$1@babylon.agtel.net>


The problem probably lies in the server-side character set conversion on the way between the database server and mod_plsql because mod_plsql retrieves your binary data as character data. Take a look at WPG_DOCLOAD package supplied with OWA (it is actually part of Portal framework, but is universal). It has several overloaded file download routines, one of which is used to supply file content from a BLOB. If you don't have this package, upgrade to the latest OWA (3.0.0.0.5 is last I know of), it is supplied with mod_plsql patches. Using this package, feeding BLOB for download is trivial. Upgrading mod_plsql itself is a must also (3.0.9.8.3c is latest version for iAS 1.0.2 and Oracle 8i/9iR1) as initial releases had numerous security issues and other bugs which were fixed in several consecutive patches. You can check your current mod_plsql version by opening administrative interface (/pls/any_dad/admin_/gateway.htm) and looking for version number in the lower-right corner of the page. Securing this path is also a good idea (or at least change default admin_ prefix to something less obvious in wdbsvr.app file) to prevent unwanted people looking at your DADs and even modifying them.

--
Vladimir Zakharychev (bob@dpsp-yes.com)                http://www.dpsp-yes.com
Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet applications.
All opinions are mine and do not necessarily go in line with those of my employer.


"Benoit Hebert" <bhebert_at_borabora.crchul.ulaval.ca> wrote in message
news:3D0E4C1A.15FA06_at_borabora.crchul.ulaval.ca...

> Hi folks.
>
> We've loaded a JPG image into a Blob in our database, and we want to
> retrieve it, and display it in the user's Web browser, using a PL/SQL
> procedure. We've used Tom Kyte's image_get procedure, and changed the
> mime header for JPEG files. However, the procedure doesn't work - we get
> a broken image link as a result.
>
> We know the image was loaded correctly into the database. A Perl script
> can fetch it, and we've confirmed through visual inspection and through
> a checksum that the image is the same as the original. I tried
> right-clicking the broken image link and saving it as a local file, and
> the image is corrupted.
>
> Here is the image_get package body:
>
> CREATE OR REPLACE package body insitu.image_get
> AS
>
> procedure jpg (p_id in images.no_image%type)
> AS
> s_image blob;
> l_amt number default 30;
> l_off number default 1;
> l_raw raw(4096);
>
> BEGIN
>
> SELECT fichier_image INTO s_image FROM images WHERE no_image = p_id;
>
> owa_util.mime_header( 'image/jpeg' );
>
> begin
> LOOP
> dbms_lob.read(s_image, l_amt, l_off, l_raw);
> htp.prn( utl_raw.cast_to_varchar2( l_raw ));
> l_off := l_off + l_amt;
> l_amt := 4096;
> END LOOP;
>
> EXCEPTION
> when no_data_found then
> NULL;
>
> end;
> end;
> end;
> /
>
> The procedure is called in another PL/SQL procedure, that displays the
> complementary information.
>
> htp.print(' <TD ALIGN="Center" COLSPAN-"4"><IMG
> SRC="/pls/invivo/insitu.image_get.jpg?p_id=' || pNo_Image || '"></TD>');
>
>
>
> We're thinking that this might be a mime problem, but we can't quite
> figure it out. Does anybody have any ideas that might help?
>
> Thanks a lot!
>
> --
> Benoit Hebert
> Assistant de Recherche - Bioinformatique
> Research Assistant - Bioinformatics
> Centre Hospitalier de l'Universite Laval
>
Received on Tue Jun 18 2002 - 03:35:32 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US