Skip to main content
Participating Frequently
October 9, 2006
Answered

Binary conversion within <cfoutput> tags

  • October 9, 2006
  • 11 replies
  • 727 views
I'm performing a 'readBinary' action with the <cffile> tag on Word docs, Excel spreadsheets, or PDF's, then converting the file contents to Base64 and storing the result in a SQL Server 2005 text field. I'm trying to display the original file contents in a Coldfusion template using the <cfcontent> tag. However, converting the Base64 data back to binary between <cfouput> tags is yielding the error: 'ByteArray objects cannot be converted to strings'.

Does anyone know how I can display the original file without having to write it back to the server's file system? Please refer to the following code.
This topic has been closed for replies.
Correct answer Stefan_K_
Outputting binary data to browser rang some bell here ... maybe this link helps, haven't tested it:

http://weblogs.macromedia.com/cantrell/archives/2003/06/using_coldfusio.cfm

11 replies

jkyzarAuthor
Participating Frequently
October 12, 2006
That solution works fine. Thanks Stefan!
Stefan_K_Correct answer
Inspiring
October 12, 2006
Outputting binary data to browser rang some bell here ... maybe this link helps, haven't tested it:

http://weblogs.macromedia.com/cantrell/archives/2003/06/using_coldfusio.cfm
jkyzarAuthor
Participating Frequently
October 11, 2006
Thanks. I will look into that.
Inspiring
October 11, 2006
Have you looked at what might be accomplished with Java? Even 6.1 was
fairly easily extended with Java.
jkyzarAuthor
Participating Frequently
October 11, 2006
I was just hoping to be able to implement what I thought was the best possible solution for my problem. Writing the files back to the file system was my backup plan/last resort all along. CF6.1 does not offer thread control to the programmer either, so the trick is making sure the file is complete before it gets sent to the client. I hope that using 2 <cflock> tags with the same name and an exclusive lock will ensure success.

P.S. I really do appreciate the input. I'm just a little frustrated right now.
jkyzarAuthor
Participating Frequently
October 11, 2006
I was just hoping to be able to implement what I thought was the best possible solution for my problem. Writing the files back to the file system was my backup plan/last resort all along. CF6.1 does not offer thread control to the programmer either, so the trick is making sure the file is complete before it gets sent to the client. I hope that using 2 <cflock> tags with the same name and an exclusive lock will ensure success.

P.S. I really do appreciate the input. I'm just a little frustrated right now.
Inspiring
October 11, 2006
Is it such a big deal if you write the file to a temp location on the
file system, server it up, and the clean up at a later time. That would
work in 6.1.

Sorry if a three+ year old system doesn't do what you need it to do, by
all means go with a newer one that does. Just remember that 6.1
predates the current ASP.NET so I doubt you would have had much luck
with a solution in that language when 6.1 was new and shinny.
jkyzarAuthor
Participating Frequently
October 11, 2006
Thanks anyway. I thought that what I'm trying to accomplish was a fairly common thing and certainly do-able in CF. I thought wrong! As advanced as I thought Coldfusion MX6.1 was, it falls miserably short. My boss sure isn't gonna be happy that what he wants done isn't possible in CF, unless he puts out the cash for a CF7 upgrade. Now I'm glad my company is transitioning to ASP.Net.
jkyzarAuthor
Participating Frequently
October 10, 2006
Thanks, but I wish I could use that solution. Unfortunately we're on CFMX 6.1 here and the variable attribute isn't available.
jkyzarAuthor
Participating Frequently
October 10, 2006
.