logo       

RE: Downloading BLOBS from Oracle DB: msg#00046

java.enhydra.general

Subject: RE: Downloading BLOBS from Oracle DB


>-----Original Message-----
>From: enhydra-admin@xxxxxxxxxxx [mailto:enhydra-admin@xxxxxxxxxxx] On
Behalf Of Sreedhar.Gajula@xxxxxx
>Sent: Wednesday, January 22, 2003 2:07 AM
>To: enhydra@xxxxxxxxxxx
>Subject: Enhydra: Downloading BLOBS from Oracle DB



>Hi There,

>I am trying to download a blob containing a MS word document from an
Oracle DB.
>I was able to read the blob and create a .doc file on the server and
created an hyper link to open in the webserver.
>I was wondering if there is a way to automatically create the doc file
on the fly without having to create the file on the >server.
>
>BTW I was searching on google and found your message about the same
problem.
>
>Appreciate any ideas on this.
>
>Thanks
>
>Sreedhar Gajula

Hi!
Last year in May, somebody ask something simular.
Here is my answer and the original question:

Hi!

I wrote a PO to retrieve a PDF or HTML - file dynamically from a
MySQL-Database and upload it to the client.

Here is the code:
========================================================================
=======
/*
* Pdf
*
* (c) 2002 fellowhome.de GmbH
*
*/

package fellowhome.presentation.pdfs;

import com.lutris.appserver.server.httpPresentation.*;

import fellowhome.FellowhomeException;
import fellowhome.data.objekt.ProjektDO;
import fellowhome.data.objekt.PrblobDO;
import fellowhome.data.objekt.PrblobQuery;

/**
* <b>Title:</b> Pdf - Präsentationsobjekt<br>
* <b>Description:</b> PO zum Ausgeben von Pdfs<br>
* <b>Company:</b> fellowhome.de GmbH<br>
* @author Thorsten Hilker
* @version 1.0
*/

public class Pdf implements HttpPresentation {

// Methode die ausgeführt wird, wenn das PO aufgerufen wird
public void run(HttpPresentationComms comms)
throws Exception {

// ProjektID aus der URL einlesen
String projektID = comms.request.getParameter("projektID");

if (projektID == null) {
projektID = "";
}

// PDF-Typ und Name aus der URL einlesen
String pdfTP = comms.request.getParameter("pdfTP");
String pdfNA = comms.request.getParameter("pdfNA");

// Das Objekt aus der Datenbank einlesen
ProjektDO pDO = ProjektDO.createExisting(projektID);
PrblobQuery pQuery = new PrblobQuery();
pQuery.requireUniqueInstance();
pQuery.setQueryPrid(pDO);
pQuery.setQueryBltp(pdfTP);
PrblobDO pbDO = pQuery.getNextDO();
if (pbDO == null)
throw new FellowhomeException(this, 2, "Das Dokument wurde nicht
gefunden!", "---");

// Stream erzeugen
if (pdfTP.equals("bpdf")) {
comms.response.setContentType("application/pdf");
}
if (pdfTP.equals("bhtm")) {
comms.response.setContentType("text/html");
}
comms.response.setContentLength(pbDO.getBdat().length);
comms.response.setHeader("Content-Disposition",
"filename=" + '"' + pdfNA + '"');

// Stream aufgrund des Typs füllen und senden
HttpPresentationOutputStream stream =
comms.response.getOutputStream();
stream.write(pbDO.getBdat());

stream.flush();
}
}
========================================================================
===
The Href to call this PO looks like this:

<A href="/dyn/pdfs/Pdf.po?projektID=176775&pdfTP=bpdf&pdfNA=Seeschloss
Hermsdorf.pdf" id="Bbpd" type="application/pdf"><IMG border="0"
height="11" src="/pics/link.gif" width="13">Baubeschreibung im
PDF-Format</A>

The parameters "projektID=176775&pdfTP=bpdf&pdfNA=Seeschloss
Hermsdorf.pdf id=Bbpd" are build dynamically by another PO which builds
the page which is shown in the browser.

If you want to upload wordfiles you have to use the mime-type
"application/msword" instead of "application/pdf" in the code and in the
Href.

Hope that helps.
If you have further questions let me know.

Greetings!
Thorsten

PS The comments in the code are in German, sorry :)
PPS If you want to see how it works go to our website:
http://www.fellowhome.de/dyn/immosuche/ObjtHaus.po
then press "zu den Details"
then press "Baubeschreibung"
then press "Baubeschreibung im PDF-Format"

> -----Original Message-----
> From: enhydra-admin@xxxxxxxxxxx
> [mailto:enhydra-admin@xxxxxxxxxxx] On Behalf Of Dr Louis Coetzee
> Sent: Thursday, May 23, 2002 10:44 AM
> To: enhydra@xxxxxxxxxxx
> Cc: Moses Marivatse; Ilse Viviers
> Subject: Enhydra: File download from blobs
>
>
> Hi,
>
> I have a number of word documents (or other unfriendly binary
> formats) stored
> in a blob in a Oracle database.
>
> I need to provide a HTML page providing a link (url) that the
> user can click
> on to download this document to his/her own machine.
>
> The one possibility I can think of is to read the blob and
> write it to disk
> (e.q. /tmp/documentname) and then dynamically add a URL
> reference to this file
> on disk on the html page. The problem with this is that the
> size of the /tmp
> will grow the whole time.
>
> Is there a way how I can provide a URL to the document,
> without writing it to
> a tmp storage first ? I.e. access the blob directly in the database ?
>
>
> Well later
>
> Louis
>
>
> _______________________________________________
> Enhydra mailing list
> Enhydra@xxxxxxxxxxx
> http://www.enhydra.org/mailman/listinfo.cgi/en> hydra
>



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise