Thoughts, ideas, tips, musings, and pontifications (not necessarily in that order) by Ben Forta ...
NOTE: This is my personal blog, and the opinions and statements voiced here are my own.
August 26, 2008
Posted At : 11:23 AM
Related Categories:
ColdFusion
A TechNote posted last week explains how to stream images in ColdFusion, and provides simple sample code.
There are no trackbacks for this entry.
No trackback URL. Trackbacks are only allowed via interactive form.
|
The CFContent tag has a Variable attribute that allows you to pass in a binary variable:
<cfcontent type="image/jpeg" variable="#qData.blob#" />
I feel like the advent of CFContent got rid of many of the needs to go directly into the response object to do things.
-Randy
Whether you are writing to the Response object or using the CFContent tag, I *assume* that it still keeps the single thread busy with the binary data transfer. After all, something still needs to be flushing the response to the client.
I believe the only way to get around this is to pass of the file request to a static file server (I think something that Apache can do inherently, but not IIS).
I think the problem there is that on a CFImage-created binary, there is no "file type" until the image is saved. Therefore, I think there are problems streaming the underlying BLOB data because it has no particular encoding?? I am only guessing here, but I think that is the problem I have run into.
If that *is* the problem, I think you will still encounter the same issue - that no compression / file type is defined..... but totally guessing here :)
I tested this with a very large image, and both techniques loaded the image in the same amount of time.
One of the servers I have access to has sandbox security turned on. cfcontent is not allowed, but cffile is allowed, and the code in the technote works on that server. So there's one advantage. If you're allowed to use cffile but not cfcontent, this is a workaround.
Good point re: security concerns. As for the content length, you can add that using CFheader:
<cfheader name="content-length" value="#ArrayLen( binaryData )#" />
<cfcontent .... />