Re: Sending binary directly to the browser?
This IS unlikely to be the case, but it just may be! Ok, but since I don't have the original one pixel image, I cannot run the test from begining under CF 5. What I can do however, is read another image, Base64-it, and re-binarize it, and see. I did it, and I still get an error when outputing the file as a string, because of the presence of zero bytes. One must conclude that it worked with CF 4.5, it was bugged in version 5, then fixed in version 6. ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
Re: Sending binary directly to the browser?
The below should do the trick for you. cfcontent type=image/gif; charset=8859_1 cfoutput#gifdatahere#/cfoutput Matt Liotta President CEO Montara Software, Inc. http://www.MontaraSoftware.com (888) 408-0900 x901 ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Get the mailserver that powers this list at http://www.coolfusion.com
Re: Sending binary directly to the browser?
cfcontent type=image/gif; charset=8859_1 cfoutput#gifdatahere#/cfoutput I've tried, but it does not work. If gifdatahere contains binary, CFCONTENT complains it can accept only a string, if it is a string, the string is truncated to the first zero byte. ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Get the mailserver that powers this list at http://www.coolfusion.com
RE: Sending binary directly to the browser?
tried delivering the gif via cfcontent directly??? cfcontent type=image/gif; charset=8859_1 file=C:\foo\goo.gif deletefile=No Doug -Original Message- From: Claude Schneegans [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 11:04 AM To: CF-Talk Subject: Re: Sending binary directly to the browser? cfcontent type=image/gif; charset=8859_1 cfoutput#gifdatahere#/cfoutput I've tried, but it does not work. If gifdatahere contains binary, CFCONTENT complains it can accept only a string, if it is a string, the string is truncated to the first zero byte. ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
Re: Sending binary directly to the browser?
cfcontent type=image/gif; charset=8859_1 cfoutput#gifdatahere#/cfoutput I've tried, but it does not work. If gifdatahere contains binary, CFCONTENT complains it can accept only a string, if it is a string, the string is truncated to the first zero byte. You aren't supposed to put the binary data in the cfcontent tag. If you look at the use of cfcontent I shared it only contains a string specifying what type to use. You output the binary data to the response using cfoutput. Matt Liotta President CEO Montara Software, Inc. http://www.MontaraSoftware.com (888) 408-0900 x901 ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. http://www.cfhosting.com
RE: Sending binary directly to the browser?
Are you sure it's binary data? Does it return true when you try isBinary(gifdatahere)?? You can try outputting the data to the output stream directly by utilizing the underlying page context. Christian Cantrell blogged an example of doing this here: http://www.markme.com/cantrell/archives/002658.cfm André -Original Message- From: Claude Schneegans [mailto:[EMAIL PROTECTED] Sent: 05 September 2003 16:04 To: CF-Talk Subject: Re: Sending binary directly to the browser? cfcontent type=image/gif; charset=8859_1 cfoutput#gifdatahere#/cfoutput I've tried, but it does not work. If gifdatahere contains binary, CFCONTENT complains it can accept only a string, if it is a string, the string is truncated to the first zero byte. ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
Re: Sending binary directly to the browser?
tried delivering the gif via cfcontent directly??? Sure, it works, I have the CF_ tag to write the file, then CFCONTENT sends the file, but this means the file must be written then read again for nothing. The overhead is significant. What I want is return the gif image directly to the browser from the variable I have in memory without unnecessary disk i/0. If it was a cgi application, I'd just output to stdout from my C program: cfcontent type=image/gif then the content of the image, and it works. I even done it from a Clipper program, no problem. I tried to do it from my CFX_ in C, but it does not work. I suspect CF is flushing what the CFX_ put in the stdout and keeps it for its own use. ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
Re: Sending binary directly to the browser?
Christian Cantrell blogged an example of doing this here: Yeah, this is exactly what I was looking for, thanks a lot. I guess this will only work with CFMX, but at least I'll have a more efficient solution for generations to come ;-) ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Get the mailserver that powers this list at http://www.coolfusion.com
RE: Sending binary directly to the browser?
One thing about this: make sure to use CFSILENT to ensure that the first character of your output is the first character of the GIF file. Also note that CF debug output will kill you. Secondly you may have to use some combination of ToString() and ToBinary() to do this. For example the following happily places a single pixel GIF on the screen with no file system access: cfsilent cfsetting showdebugoutput=No / cfcontent type=image/gif; charset=8859_1 /cfsilentcfoutput#ToString(ToBinary(R0lGODlhAQABAIAAAP///wAAACH5BAE ALAABAAEAAAICRAEAOw==))#/cfoutput That's probably a little more complex than you need since I used Tobase64() to encode the graphic (but this makes for a fully printable string - just using ToString() creates a lot of non-printable characters - something that may not matter to you). In my case I was aiming to store the encoded graphic in a database, thus the ToBase64(). Jim Davis -Original Message- From: Matt Liotta [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 10:44 AM To: CF-Talk Subject: Re: Sending binary directly to the browser? The below should do the trick for you. cfcontent type=image/gif; charset=8859_1 cfoutput#gifdatahere#/cfoutput Matt Liotta President CEO Montara Software, Inc. http://www.MontaraSoftware.com (888) 408-0900 x901 ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
RE: Sending binary directly to the browser?
Just as a note - the solution I just posted works in 4.5 and above. Jim Davis -Original Message- From: Claude Schneegans [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 12:47 PM To: CF-Talk Subject: Re: Sending binary directly to the browser? Christian Cantrell blogged an example of doing this here: Yeah, this is exactly what I was looking for, thanks a lot. I guess this will only work with CFMX, but at least I'll have a more efficient solution for generations to come ;-) ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
Re: Sending binary directly to the browser?
I tried on CF 5.0 and I still get the error: An error occurred while evaluating the expression: #ToString(ToBinary(R0lGODlhAQABAIAAAP///wAAACH5BAEALAABAAEAAAICRAEAOw==))# Error near line 9, column 23. This object cannot be converted to a string (it contains null characters). (I had to comment out the CFCONTENT tag to see the error message, otherwise IE protests it cannot get the page) In fact, the toBinary function create the image in gif format, but since it contains zeros, it cannot be converted to a string. Or am I missing something else? My code is exactly (cut'n pasted from your message): cfsilent cfsetting showdebugoutput=No / CFCONTENT TYPE=text/plain /cfsilentcfoutput#ToString(ToBinary(R0lGODlhAQABAIAAAP///wAAACH5BAEALAABAAEAAAICRAEAOw==))#/cfoutput ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
Re: Sending binary directly to the browser?
I tried on CF 5.0 and I still get the error: ... and I tried it under CFM 6 on the same computer, and it works!... If somebody got it working under CF 5.0, I'd like to know how? May be it works under CF 4.5 and 6 but is bugged on version 5? ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Get the mailserver that powers this list at http://www.coolfusion.com
Re: Sending binary directly to the browser?
Christian Cantrell blogged an example of doing this here: Actually, after lots of reading and testing, I came to the conclusion that all this is complicated for nothing. This simple code works fine under CF 6: cfsilent CFCONTENT TYPE=image/gif CFFILE action=READ file=C:\CFusionMX\wwwroot\test\myGif.gif variable=gifFile /cfsilentcfoutput#gifFile#/cfoutput The CFSILENT seems to be necessary, but cfsetting showdebugoutput=No / is not This also works: cfsilent CFCONTENT TYPE=image/gif CFFILE action=READBINARY file=C:\CFusionMX\wwwroot\test\myGif.gif variable=gifFile /cfsilentcfoutput#ToString(gifFile)#/cfoutput None of these work unde CF 5, under CF 4.x I don't know. What happens is simply that they manage to fix the problem of toString() refusing to insert zero bytes in the string, and CFOUTPUT refusion to output a string containing zero bytes, PERIOD. There is still the problem that chr(0) returns an empty string instead of a one byte string containing zero like it should. But now, we can work on the binary content as an array, so we don't need string concatanation any more. ... still looking for a work around for CF 5 ;-) ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Get the mailserver that powers this list at http://www.coolfusion.com
RE: Sending binary directly to the browser?
Instead of the cfsilent why not just reset whats being outputted... !--- as much whitespace as you want can be put here --- CFFILE action=READ file=C:\CFusionMX\wwwroot\test\myGif.gif variable=gifFile CFCONTENT TYPE=image/gif RESET=Yescfoutput#gifFile#/cfoutputCFABORT HTH Mikey -Original Message- From: Claude Schneegans [mailto:[EMAIL PROTECTED] Sent: Friday, September 5, 2003 22:13 To: CF-Talk Subject: Re: Sending binary directly to the browser? Christian Cantrell blogged an example of doing this here: Actually, after lots of reading and testing, I came to the conclusion that all this is complicated for nothing. This simple code works fine under CF 6: cfsilent CFCONTENT TYPE=image/gif CFFILE action=READ file=C:\CFusionMX\wwwroot\test\myGif.gif variable=gifFile /cfsilentcfoutput#gifFile#/cfoutput The CFSILENT seems to be necessary, but cfsetting showdebugoutput=No / is not This also works: cfsilent CFCONTENT TYPE=image/gif CFFILE action=READBINARY file=C:\CFusionMX\wwwroot\test\myGif.gif variable=gifFile /cfsilentcfoutput#ToString(gifFile)#/cfoutput None of these work unde CF 5, under CF 4.x I don't know. What happens is simply that they manage to fix the problem of toString() refusing to insert zero bytes in the string, and CFOUTPUT refusion to output a string containing zero bytes, PERIOD. There is still the problem that chr(0) returns an empty string instead of a one byte string containing zero like it should. But now, we can work on the binary content as an array, so we don't need string concatanation any more. ... still looking for a work around for CF 5 ;-) ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
RE: Sending binary directly to the browser?
Honestly I don't know I've only tested on 4.5 and MX. Now I've gotta go and do some work on this. ;^) Jim Davis -Original Message- From: Claude Schneegans [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 4:25 PM To: CF-Talk Subject: Re: Sending binary directly to the browser? I tried on CF 5.0 and I still get the error: ... and I tried it under CFM 6 on the same computer, and it works!... If somebody got it working under CF 5.0, I'd like to know how? May be it works under CF 4.5 and 6 but is bugged on version 5? ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
RE: Sending binary directly to the browser?
Weird... there are no null characters in the string (I think). I doubt that zeros are the problem (unless zero converts to null in Base64) as zero is a value, not null. One thing however - the string I got was constructed on CF 4.5 - perhaps you have to create your string in CF 5.0? Perhaps it's having trouble decoding across versions? (It shouldn't have, but maybe it does) Weird. Jim Davis -Original Message- From: Claude Schneegans [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 3:53 PM To: CF-Talk Subject: Re: Sending binary directly to the browser? I tried on CF 5.0 and I still get the error: An error occurred while evaluating the expression: #ToString(ToBinary(R0lGODlhAQABAIAAAP///wAAACH5BAEALAABAAEAAAIC RA EAOw==))# Error near line 9, column 23. This object cannot be converted to a string (it contains null characters). (I had to comment out the CFCONTENT tag to see the error message, otherwise IE protests it cannot get the page) In fact, the toBinary function create the image in gif format, but since it contains zeros, it cannot be converted to a string. Or am I missing something else? My code is exactly (cut'n pasted from your message): cfsilent cfsetting showdebugoutput=No / CFCONTENT TYPE=text/plain /cfsilentcfoutput#ToString(ToBinary(R0lGODlhAQABAIAAAP///wAAACH5BAE AA AAALAABAAEAAAICRAEAOw==))#/cfoutput ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
RE: Sending binary directly to the browser?
Good idea. However the CFABORT has me worried - in that case your OnRequestEnd.cfm wouldn't run (which may be a bad thing). Using CFSILENT you can run things after as well. I guess it's kind of six of one, half dozen of the other. Jim Davis -Original Message- From: Mike Townend [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 5:27 PM To: CF-Talk Subject: RE: Sending binary directly to the browser? Instead of the cfsilent why not just reset whats being outputted... !--- as much whitespace as you want can be put here --- CFFILE action=READ file=C:\CFusionMX\wwwroot\test\myGif.gif variable=gifFile CFCONTENT TYPE=image/gif RESET=Yescfoutput#gifFile#/cfoutputCFABORT HTH Mikey -Original Message- From: Claude Schneegans [mailto:[EMAIL PROTECTED] Sent: Friday, September 5, 2003 22:13 To: CF-Talk Subject: Re: Sending binary directly to the browser? Christian Cantrell blogged an example of doing this here: Actually, after lots of reading and testing, I came to the conclusion that all this is complicated for nothing. This simple code works fine under CF 6: cfsilent CFCONTENT TYPE=image/gif CFFILE action=READ file=C:\CFusionMX\wwwroot\test\myGif.gif variable=gifFile /cfsilentcfoutput#gifFile#/cfoutput The CFSILENT seems to be necessary, but cfsetting showdebugoutput=No / is not This also works: cfsilent CFCONTENT TYPE=image/gif CFFILE action=READBINARY file=C:\CFusionMX\wwwroot\test\myGif.gif variable=gifFile /cfsilentcfoutput#ToString(gifFile)#/cfoutput None of these work unde CF 5, under CF 4.x I don't know. What happens is simply that they manage to fix the problem of toString() refusing to insert zero bytes in the string, and CFOUTPUT refusion to output a string containing zero bytes, PERIOD. There is still the problem that chr(0) returns an empty string instead of a one byte string containing zero like it should. But now, we can work on the binary content as an array, so we don't need string concatanation any more. ... still looking for a work around for CF 5 ;-) ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Get the mailserver that powers this list at http://www.coolfusion.com
Re: Sending binary directly to the browser?
I doubt that zeros are the problem (unless zero converts to null in Base64) as zero is a value, not null. No, there are no zeros in base64, since the purpose is to represent any 8 bit value within 6 bits regular character. BUT, when going back to binary, then you will find zeros again. Thus ToBinary( will return a binary bloc containing zeros, and ToString( protests. This is definitely a bug in CF 5, since it is supposed to support ASCII strings, and ASCII is a 256 character set, from 0 to 255. perhaps you have to create your string in CF 5.0? No, just cut'n pasted from your message. ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
Re: Sending binary directly to the browser?
Instead of the cfsilent why not just reset whats being outputted... Why not indeed. It works also, even simpler. ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Get the mailserver that powers this list at http://www.coolfusion.com
RE: Sending binary directly to the browser?
-Original Message- From: Claude Schneegans [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 7:07 PM To: CF-Talk Subject: Re: Sending binary directly to the browser? I doubt that zeros are the problem (unless zero converts to null in Base64) as zero is a value, not null. No, there are no zeros in base64, since the purpose is to represent any 8 bit value within 6 bits regular character. BUT, when going back to binary, then you will find zeros again. Thus ToBinary( will return a binary bloc containing zeros, and ToString( protests. This is definitely a bug in CF 5, since it is supposed to support ASCII strings, and ASCII is a 256 character set, from 0 to 255. perhaps you have to create your string in CF 5.0? No, just cut'n pasted from your message. I'm sorry - you misunderstood. I meant that the original string was encoded using CF 4.5 - and can be decoded properly. Perhaps if you encoded the file using 5.0 it would eliminate the problems decoding? Jim Davis ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
Re: Sending binary directly to the browser?
I meant that the original string was encoded using CF 4.5 - and can be decoded properly. Perhaps if you encoded the file using 5.0 it would eliminate the problems decoding? Well, I'll try, but I doubt it makes any difference. Base64 is not some internal format proper to CF that may change from one version to another: It is an Internet standard. Your assumption would imply that CF 4.5 encodes wrong base64 but still decoded back right, or the same thing about CF 5. I think if this was the case, this should be known. I get the same error anyway when I read a gif file, so if there is an error, it is in CF 5. ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
RE: Sending binary directly to the browser?
-Original Message- From: Claude Schneegans [mailto:[EMAIL PROTECTED] Sent: Friday, September 05, 2003 10:56 PM To: CF-Talk Subject: Re: Sending binary directly to the browser? I meant that the original string was encoded using CF 4.5 - and can be decoded properly. Perhaps if you encoded the file using 5.0 it would eliminate the problems decoding? Well, I'll try, but I doubt it makes any difference. Base64 is not some internal format proper to CF that may change from one version to another: It is an Internet standard. Which is why I said it shouldn't matter in the first place. ;^) Your assumption would imply that CF 4.5 encodes wrong base64 but still decoded back right, It's not an assumption really - I doubt it will work. However I used CF 4.5 to encode the string, and it decodes just fine in CF 4.5 (and MX). However IF CF 5.0 has a bug in it's decoding process it may be that the same bug is shared by the encoding process. This may be the reason that it made it through CF 5's testing: it can decode its own encoded strings, but not those of other versions. This IS unlikely to be the case, but it just may be! Obviously some version of CF just doesn't follow the standard very well. Jim Davis ~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. http://www.cfhosting.com