• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Binary conversion within <cfoutput> tags

New Here ,
Oct 09, 2006 Oct 09, 2006

Copy link to clipboard

Copied

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.
TOPICS
Advanced techniques

Views

524

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Oct 12, 2006 Oct 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

Votes

Translate

Translate
Enthusiast ,
Oct 10, 2006 Oct 10, 2006

Copy link to clipboard

Copied

I believe the issue is that you should be using cfcontent itself to output the file and not cfoutput. I am using CFMX7. I have inserted a word doc into my mssql document table. The doc column is type text and I inserted the cffile readBinary as base64.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 10, 2006 Oct 10, 2006

Copy link to clipboard

Copied

.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 10, 2006 Oct 10, 2006

Copy link to clipboard

Copied

Thanks, but I wish I could use that solution. Unfortunately we're on CFMX 6.1 here and the variable attribute isn't available.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 11, 2006 Oct 11, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 11, 2006 Oct 11, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 11, 2006 Oct 11, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 11, 2006 Oct 11, 2006

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 11, 2006 Oct 11, 2006

Copy link to clipboard

Copied

Have you looked at what might be accomplished with Java? Even 6.1 was
fairly easily extended with Java.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 11, 2006 Oct 11, 2006

Copy link to clipboard

Copied

Thanks. I will look into that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 12, 2006 Oct 12, 2006

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 12, 2006 Oct 12, 2006

Copy link to clipboard

Copied

LATEST
That solution works fine. Thanks Stefan!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation