Daniel
Daniel

Reputation: 35724

coldfusion - storing text as binary data

I'd like to store my text as a binary data with coldfusion. The problem I'm having is that the file ends up being binary-encoded text stored as text.

this is the code I'm using

// create
FileWrite(LOCAL_FILE_DATA, binaryEncode(toBinary(toBase64("")),"Hex"));

// append
LOCAL_FILE = FileOpen(LOCAL_FILE_DATA,"append");
FileWrite( LOCAL_FILE, binaryEncode(toBinary(toBase64(LOCAL_DATA)),"Hex") );

Is there something simple I'm missing that is causing information to be saved as text rather than binary?

if I only use FileWrite( LOCAL_FILE, toBinary(toBase64(LOCAL_DATA)) );, then it only writes the text data

the data I'm trying to write looks something like this "2013-08-04 07:49:21","::1","","","","","","","","","","","","" I'm using a local server so the ip is not being resolved, I'm either seeing that in the file or something like this 22323031332D30382D30342030343A31333A3038222C223A3A31222C22222C22222C2

but in both cases the file is a text file.

Upvotes: 0

Views: 351

Answers (1)

Adam Cameron
Adam Cameron

Reputation: 29870

Am I missing something, or is the reason your file output ends up being binary encoded text because you're very specifically converting it to that with binaryEncode() before you write it?

If you don't want to do that then... well... don't!

Upvotes: 3

Related Questions