Re: File Upload/Display in OAS

From: Ms. D.H. Harvey <qq45_at_liverpool.ac.uk>
Date: 2000/05/15
Message-ID: <8fom2m$scp$1_at_news.liv.ac.uk>#1/1


Joel Racicot (joelracicot_at_home.com) wrote:
: Hi Folks,
 

: I've been struggling with the following problem for a few weeks and I'd
: like to run this by you all.
 

: I need to upload a file (typically an image) to a table and then be able
: to retrieve and display it to a web page. All these actions occur
: through OAS.
 

: The table is structured as follows:
 

: Create table BLOBTEST (
: name varchar2(100),
: content BLOB);
 

: I am able to retrieve the image from my table using the following
: procedure:
 

: PROCEDURE Getimage
 

: /* The calling proc (STORES) is passing the name of the image to be
: retrieved from
: the image table BLOBTEST. */
 

: (
: p_id IN BLOBTEST.name%TYPE /* VENDORS.logo = BLOBTEST.content */
: )
 

: IS
 

: l_lob blob; /* BLOBTEST.content */
: l_amt NUMBER DEFAULT 30;
: l_off NUMBER DEFAULT 1;
: l_raw RAW(4096);
: l_gif NUMBER(2);
: l_jpg NUMBER(2);
 

: BEGIN
 
: /* Get the image from the BLOBTEST table based on the name that was
: passed from the calling procedure. */
 

: SELECT content
: INTO l_lob
: FROM BLOBTEST
: WHERE name = p_id;
 

: owa_util.mime_header('image/gif');
 

: /* Pass the image out to the the browser. */
: BEGIN
: LOOP
: dbms_lob.read( l_lob, 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
: htp.prn('No image found');
: END;
: END;

: I am also able to upload a file to OWS_CONTENT using the built-in
: packages granted to OWS_STANDARD_ROLE.
 

: My problem is I haven't found how to extract the image from OWS_CONTENT
: to display on the web page and I haven't figured out how to load the
: image into the BLOBTEST table.

Take a look at the to_lob function. Note doesn't seem to be implemented in pl/sql so need to use dynamic sql.

HTH Helen
: So, as you can see, I have half a solution using either option.
 

: I am doing this on the side for a friend and I'd like to pick your
: brains to resolve this so my friend can move on.
 

: The OWA_REPL cartridge, made available by Thomas Kyte, would probably do
: it for me, unfortunately, I have no access to the box to install this
: and apparently, according to the dba, there is no C compiler, therefore
: this option is unavailable to me.
 

: Any help or thoughts you might be able to give me would be greatly
: appreciated.
 

: Thanks
 

: Joel
Received on Mon May 15 2000 - 00:00:00 CEST

Original text of this message