ByteArray objects cannot be converted to strings

(There’s no tag for “Oracle”?) :smile:

Hello, everyone,

I posted this on the Adobe forum, yesterday; but after a day it has only 20 views and zero responses (it may be an Oracle issue, not an Adobe issue.)

I’m attempting to SELECT a blob from an Oracle db, and use CFIMAGE action=“writeToBrowser” to display the image.

<CFIMAGE action="writeToBrowser" source="#qry.IMAGEDATA#" format="png" /> 

It’s giving me the error message “ByteArray objects cannot be converted to strings”. The datatype is “BLOB”, not varchar.

I’m running CF10 update 15 on a Windows7 system, with Oracle 11g. Am I missing a step, somewhere?

V/r,

:slight_smile:

edit nvm no idea

looking at the docs it looks fine to me.

I’ll probably delete this comment later.

1 Like

The CF has a IF condition that will not display an image if the length of the data in IMAGEDATA is 0, so there is something in that column, and it is an image (SQL Developer can display the image - it’s there.)

I’m thinking, more and more, that it’s because I’m just doing “SELECT n.IMAGEDATA FROM NEWSIMAGES n WHERE n.newsID = [id]”. Should I be doing something in the query to indicate that this is binary, not varchar?

Thanks,

:slight_smile:

I haven’t got a clue but if I follow your train of thought, I don’t see why. BLOB is binary by default and the database should know that.

What I don’t know if the action “writeToBroswer” is ready to write only text and therefore tries to convert the BLOB into something that it is not

In ColdFusion, CFIMAGE can use as the source a FQDN URL, a relative path, a full physical path, or a variable that contains the binary array. The action “writeToBrowser” doesn’t save the data to the hard drive; it does it all in memory, which is cleared as soon as the page is done rendering. Or when GC sweeps through, I’m not sure which.

But, yeah, I thought binary would be passed from the BLOB column in the database; at least, that’s the way MS-SQL does it. But apparently Oracle is a different beast, I guess?

V/r,

:slight_smile:

Each database has its ups and downs. You may be right though because according to this article, somehow BLOB in its different forms (TINYBLOB, LARGEBLOB, etc.) do have something in common with strings, even if the defintion itseff is Binary.

https://docs.oracle.com/cd/E17952_01/refman-5.1-en/blob.html

My only question about this article is that at one point mentions MySQL so I don’t know if the info is generic for any database made by Oracle or specific for MySQL

Edit: In another article I’ve read that a BLOB field should not have a NULL value. To do so, the field can be created with a default value of EMPTY_BLOB()

The same article explains how to deal with a media file saved in that BLOB field. To do so, it uses UTF_FILE
This is the code posted in the article (I don’t link to it because it is in Spanish)

Sorry that it is an image… but it was posted as an image in the original article.

1 Like

Thanks, @molona. If I can do that in a query, I’ll give that a shot. If not, I might be screwed as the PTB don’t allow STORED PROC. Although I might be able to convince the DBA to create a function. :smile:

V/r,

:slight_smile:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.