Tuesday, January 27, 2009

Binary Object Decoding, Transmitting, Encoding Using Coldfusion

As we start delving into storing binary objects (pdf's, images etc) this post will help you encode, decode and/or transmit the data you are working with. Now I am coming from the perspective of a CF developer so you will need to adapt where need be for environment.

We start with a Binary Object (an image).

1. Binary Object
2. Convert it to base64 for transmitting via xml or another HTTP method
---> a. CF method: toBase64(binaryObj)
3. Receiver takes the data and encodes it back to a binary object
---> a. CF method: toBinary(base64String)


<cfquery name="q" datasource="#REQUEST.mysqldsn#">
SELECT binaryColumn <!--- This column is a longblob --->
FROM mytable

<!--- View the data from the DB call --->
<cfdump var="#q#">

<!--- Create a way to view the binary object --->
<cfset myImg1 = ImageNew(q.document)>
<cfimage action="WRITETOBROWSER" source="#myImg1#">

<!--- Now convert the binary object from the DB to a base64 string --->
<cfset doc = tobase64(q.document)>
<!--- Display the base64 string --->

<!--- Convert the base64 string to a binary object --->
<cfset doc = toBinary(doc)>

<!--- Dump the converted base64 to a binary object to view it --->
<cfdump var="#doc#">

<!--- Create a way to view the binary object --->
<cfset myImg2 = ImageNew(doc)>
<cfimage action="WRITETOBROWSER" source="#myImg2#">

Note: Be sure you change your CFADMIN longblob size limits if you need to store large binary objects. Otherwise the data will be truncated.


Anonymous said...

There's certainly a lot to know about this issue. I like all of the points you've

My blog post; domain hosting

Anonymous said...

Hi! I know this is kind of off-topic but I had to ask. Does running a well-established website such as yours require a
large amount of work? I am brand new to running a blog but I do write in
my journal everyday. I'd like to start a blog so I will be able to share my experience and feelings online. Please let me know if you have any kind of recommendations or tips for brand new aspiring blog owners. Thankyou!

Feel free to surf to my website: designer mode Outlet

Anonymous said...

Hello there! I know this is kind of off topic but I was wondering if you
knew where I could find a captcha plugin for my
comment form? I'm using the same blog platform as yours and I'm having difficulty finding
one? Thanks a lot!

My website refinancing private student Loans

Anonymous said...

Hi! Would you mind if I share your blog with my myspace group?
There's a lot of folks that I think would really appreciate your content. Please let me know. Thank you

Here is my webpage - web hosting solution

Anonymous said...

I think the admin of this site is genuinely working hard for his
website, as here every information is quality based

My website; online store kleidung

Anonymous said...

Your way of describing all in this paragraph is in fact pleasant, all can effortlessly
understand it, Thanks a lot.

Here is my webpage; 1 seo experts

Anonymous said...

At this time I am going to do my breakfast,
when having my breakfast coming yet again to read additional news.

Here is my web blog: is interest on a home equity loan deductible

Anonymous said...

I'm excited to uncover this web site. I need to to thank you for ones time just for this wonderful read!! I definitely really liked every bit of it and i also have you saved as a favorite to check out new things on your website.

Take a look at my web-site ... where To Promote Clickbank products

Anonymous said...

Thank you a lot for sharing this with all of us you really understand what you're speaking about! Bookmarked. Please additionally discuss with my website =). We can have a hyperlink exchange agreement between us

my web blog - beach getaways

Anonymous said...

The other day, while I was at work, my sister stole my
apple ipad and tested to see if it can survive a 25 foot drop,
just so she can be a youtube sensation. My apple ipad
is now broken and she has 83 views. I know this is entirely off topic but I had to share it with someone!

Look into my web page ... kreditrechner ohne schufa

Anonymous said...

Aw, this was an incredibly good post. Taking a few minutes and actual
effort to make a very good article… but what can I say… I hesitate a whole
lot and never seem to get anything done.

Also visit my webpage: private versicherungen vergleich

Anonymous said...

Keep this going please, great job!

Feel free to visit my web page - new business ideas for entrepreneurs

Anonymous said...

Valuable info. Lucky me I discovered your web site by chance, and I am shocked why this accident
didn't happened in advance! I bookmarked it.

Feel free to visit my blog post :: bad credit student loan

Anonymous said...

My brother recommended I might like this website.
He was totally right. This post actually made
my day. You cann't imagine simply how much time I had spent for this info! Thanks!

Here is my blog ... beitrag gesetzliche krankenversicherung

Anonymous said...

Heya i am for the primary time here. I came across this board
and I find It truly useful & it helped me out a lot.
I hope to present something back and aid others like you aided me.

my web site: best all inclusive resorts

Anonymous said...

Thanks , I've just been searching for info about this subject for a long time and yours is the greatest I've came upon
so far. However, what about the bottom line?

Are you sure about the source?

Also visit my web site smart business ideas

Anonymous said...

Oh my goodness! Impressive article dude! Thank you, However I am having issues with
your RSS. I don't understand the reason why I can't subscribe
to it. Is there anybody having identical RSS issues? Anyone that knows
the solution will you kindly respond? Thanks!!

My web-site: search engine optimization uk

Anonymous said...

Hello there! This post couldn't be written any better! Reading through this post reminds me of my previous room mate! He always kept chatting about this. I will forward this post to him. Fairly certain he will have a good read. Thank you for sharing!

Check out my web site; stay at home jobs that pay well

Anonymous said...

I'm amazed, I must say. Seldom do I come across a blog that's both equally educative
and interesting, and without a doubt, you've hit the nail on the head. The problem is an issue that not enough people are speaking intelligently about. I'm very
happy I found this during my hunt for something relating to this.

My web page :: college loan consolidation calculator

Anonymous said...

Hello! Someone in my Myspace group shared this site with us so I came to check it
out. I'm definitely enjoying the information. I'm book-marking and will be tweeting this to my
followers! Outstanding blog and outstanding design.

Feel free to visit my blog ... online shopping schuhe

Anonymous said...

Keep on writing, great job!

Also visit my web page ... how to get a home loan with bad credit history

Anonymous said...

I absolutely love your blog.. Great colors & theme. Did you create this website yourself?
Please reply back as I'm planning to create my own site and would like to know where you got this from or what the theme is named. Thanks!

Feel free to visit my blog; http://cityprotocol.Org/wiki/index.Php?title=User:mitchhendr

Anonymous said...

WOW just what I was looking for. Came here by searching for
family vacation packages all inclusive

my webpage ... best vacation packages

Anonymous said...

Asking questions are in fact good thing if you are not understanding anything
entirely, except this piece of writing presents pleasant
understanding yet.

Feel free to surf to my web page - personal consolidation loans

Anonymous said...

Thanks for your marvelous posting! I truly enjoyed reading it, you are a great author.
I will always bookmark your blog and definitely will come back in the foreseeable future.
I want to encourage one to continue your great job,
have a nice afternoon!

Look into my site - einkommen private krankenversicherung

Anonymous said...

Good post. I learn something totally new and challenging on sites I stumbleupon everyday.
It will always be interesting to read through content from other writers and use a little something from their web sites.

Also visit my weblog bad credit Home Loan Lender

Anonymous said...

Why viewers still use to read news papers when in this technological world all is accessible on net?

Here is my web site ... Designer Mode Online Shop