Sample code please.
<cffile action="readbinary" file="somefile.pdf" variable="objBinaryData" />
<cfset encodedFile = BinaryEncode(objBinaryData, "Base64")>
postOnbj = StructNew();
postOnbj["fileExtension"] = deSerData.fileExtension;
postOnbj["uploadedBy"] = deSerData.uploadedBy;
postOnbj["document"] = encodedFile;
d = SerializeJSON(postOnbj); //fails to serialize JSON
Not sure if it'll make any difference but the documentation for cffile readbinary says to use ToBase64(), not BinaryEncode(). I've never used BinaryEncode for anything but I have used ToBase64. If you end up with the same results, it sounds like a bug -- not unheard of. Maybe dump out the serialized JSON result and paste it into a JSON validator and see what is screwing up.
What if you use the full path, like this
<cffile action="readbinary" file="#expandPath('somefile.pdf')#" variable="objBinaryData" />
We are running into the same issues. We are storing user images into a database via binary. Our site is heavy on the jquery side and we use ajax calls to retrieve this data. Since json does not like binary, we have to convert the binary image into base64. We then make an ajax call and reference our cfc to return the data. When using returnformat=json, we have noticed that some of the base64 data was not encoded correctly. We did string compare and noticed changes in the string.....Ben Nadal has an article that discusses these nuances in more detail. Things like U+ gets converted to u//. Not sure why this has not been fixed. Seems like a simple solution from Adobe. I hope this helps....