We did something similar. Stored the original filename to rapidly determine
mime-type. We had some peculiar latency issues so instead of directly
streaming we're writing to a temp directory.

<cfsetting enablecfoutputonly="yes"/>
<cfsetting showdebugoutput="no"/>
<cfquery name="get_upload_data" datasource="mydsn">
select file_binary, file_name
from table_about_files
where file_id = <cfqueryparam cfsqltype="cf_sql_numeric"
value="#variables.fileid#">
</cfquery>
<cfif get_upload_data.recordcount>
<cffile action="write" output="#toBinary(get_upload_data.file_binary)#"
file="/tempdirectory/#get_upload_data.file_name#" mode="777">
<!--- <cfheader name="Content-Disposition" value="attachment;
filename=#get_upload_data.file_name#"> --->
        <cfset fileext = listlast(get_upload_data.file_name,".")/>
<cfif fileext is "jpg" or fileext is "jpeg">
<cfset filetype = "image/jpeg"/>
<cfelseif fileext is "gif">
<cfset filetype = "image/gif"/>
<cfelseif fileext is "pjpeg">
<cfset filetype = "image/pjpeg"/>
<cfelseif fileext is "pdf">
<cfset filetype = "application/pdf"/>
<cfelse>
<cfset filetype = "application/x-unknown"/>
</cfif>
<cfcontent file="/tempdirectory/#get_upload_data.file_name#"
deletefile="yes" reset="no" type="#filetype#">
<cfelse>
<cfheader statuscode="404" statustext="File not Found">
<cfoutput><cfinclude template="/errorpages/404error.html"/></cfoutput>
</cfif>

On Thu, Jul 22, 2010 at 1:12 PM, Aaron Rouse <[email protected]> wrote:

> This is what we use to push out our project, data and image files.  It is
> with Oracle 10g(I think, maybe 9i).  Works with IE and Firefox(both on
> Windows and Linux).  I suppose you could store the mime types so that you
> could do the actual mime type instead of type unknown.
>
> <cfparam name="URL.LOB_ID" default="0" type="numeric" />
>
> <cfquery name="qryGetLob" datasource="#App.DataSource#">
>  SELECT BLOBDATA, SOURCE_PATH
> FROM LOB_TABLE
>  WHERE LOB_ID = <cfqueryparam value="#URL.LOB_ID#"
> cfsqltype="cf_sql_numeric" />
>  </cfquery>
> <cfif qryGetLob.RecordCount IS NOT 0>
> <cfheader name='Content-Disposition'
> value='attachment;filename=#ListLast(qryGetLob.SOURCE_PATH, "\/")#'>
>
> <cfcontent type="application/unknown" variable="#qryGetLob.BLOBDATA#">
> </cfif>
>
> On Thu, Jul 22, 2010 at 1:00 PM, Mark Davis <[email protected]> wrote:
>
>> I have some file attachments that I am reading and storing in a table (as
>> a BLOB datatype.  Having trouble  determining the process of reading the
>> BLOB back out and displaying the file to the user.  The files can be just
>> about any type (doc, xls, some type of image, you name it).  Anyone wanna
>> save me a headache?
>>
>> Thanks
>>
>> Mark
>>
>> --
>> You received this message because you are subscribed to the "Houston
>> ColdFusion Users' Group" discussion list.
>> To unsubscribe, send email to [email protected]
>> For more options, visit http://groups.google.com/group/houcfug?hl=en
>
>
>
>
> --
> Aaron Rouse
> http://www.happyhacker.com/
>
> --
> You received this message because you are subscribed to the "Houston
> ColdFusion Users' Group" discussion list.
> To unsubscribe, send email to [email protected]
> For more options, visit http://groups.google.com/group/houcfug?hl=en
>

-- 
You received this message because you are subscribed to the "Houston ColdFusion 
Users' Group" discussion list.
To unsubscribe, send email to [email protected]
For more options, visit http://groups.google.com/group/houcfug?hl=en

Reply via email to