Well, I solved it...here is the code below in case anyone else needs to do
something like this....


It is not complete but it works. Need to add some param defaults and the
such.


Basically you pass in the following:


SID = Datasource name
ID = This is the ID of the row where the blob is stored
Table = This is the Table name of the Blob
UIDFIELD = This is the fieldname in the Table Name that is the Key field for
the passed ID (whew!)
MEDIAFIELD = This is the Blob field name from the table name
DIRECTORYSET = This is the full path to where the temp files are written
(they are deleted so don't panic)


If you pass a 0 for the ID it will exit out. I will also need to add an
extension field so it can handle more than PDF's


<cfparam name="SID" default="None">
<cfparam name="ID" default="0">
<cfparam name="Table" default="None">
<cfparam name="UidField" default="ID">
<cfparam name="MediaField" default="Media">
<cfparam name="DirectorySet" default="c:\inetpub\wwwroot\Faxed\viewacts\">


<cfif #ID# IS "0">
            <p>
            General Error Occured
            </p>
            <cfabort>
<cfelse>
            <cftry>
                        <CFQUERY name="qryGetCV" datasource="#SID#">
                                    SELECT *
                                    FROM #Table#
                                    WHERE #uidfield# = #ID#
                        </CFQUERY>
                        
                        <cfcatch type="Database">
                                    A general database error has occured
trying to run the specified query!
                                    <p>
                                    SELECT *
                                    FROM #Table#
                                    WHERE #uidfield# = #ID#
                                    </p>
                                    <cfabort>
                        </cfcatch>
            </cftry>
            
            <!--- Create the Temp Files --->
            <cfdirectory directory="#DirectorySet#" name="qryFindIt">
            <cfset temp = ValueList(qryFindIt.Name)>


            <cfoutput query="qryGetCV">
                        <cfset FileVal = #Evaluate("qryGetCV." &
"#uidfield#")# & ".pdf">
                        <cfset myCount = ListValueCount(temp, FileVal)>
                        <cfif #myCount# IS "1">
                                    <!--- Skip For Now --->
                        <cfelse>
                                    <cffile action=""> file="#DirectorySet##FileVal#" output="#toBinary(Evaluate("qryGetCV." &
"#mediafield#"))#" addnewline="No">
                        </cfif>
            </cfoutput>


            <!--- Display File in Browser --->
            <!--- Also deleted the file after it has been written to
conserve space --->
            <cfoutput>
            <cfcontent file="#DirectorySet##Evaluate("FileVal")#"
type="application/pdf" deletefile="Yes">
            </cfoutput>
</cfif>

-----Original Message-----
From: Dave Watts [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 04, 2003 12:13 PM
To: CF-Talk
Subject: RE: Stream PDF using CFCONTENT


> Anyone done this, I can't remember how????

To the best of my knowledge, this isn't possible through CFCONTENT. If you
want to byte-serve PDF files, you'll have to do this through your web
server, or use something other than CF.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/ <http://www.figleaf.com/>
phone: 202-797-5496
fax: 202-797-5444
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to