Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

not able to read binary property

Avatar

Level 7

I am trying to read a "binary" type property value with below code.

resourceToRead.getValueMap().get("allFundsDup", Property.class).getBinary();

Here is the error I am getting.

result = {BinaryImpl@30400} Method threw 'java.lang.IllegalStateException' exception. Cannot evaluate org.apache.jackrabbit.oak.plugins.value.jcr.BinaryImpl.toString()
 value = {ValueImpl@30402} Method threw 'java.lang.IllegalStateException' exception. Cannot evaluate org.apache.jackrabbit.oak.plugins.value.jcr.ValueImpl.toString()

 

If I evaluate below code, it returns original stream.

resourceToRead.getValueMap().get("allFundsDup", Property.class).getBinary().getStream();

 

what I don't understand is if stream is retrievable , why does first snippet not retrieving Binary object and giving an exception.

also when I try getValueMap().get("allFundsDup", Binary.class) same exception occurs.

 

Any inputs to understand above code.

 

Thanks,

Sri

1 Accepted Solution

Avatar

Correct answer by
Level 4

Can you try the following way to return the data stream,

 

InputStream inputStream = ResourceUtil.getValueMap(resourceToRead).get("allFundsDup", InputStream .class);

 

Thanks,

Ashwin Raju

View solution in original post

1 Reply

Avatar

Correct answer by
Level 4

Can you try the following way to return the data stream,

 

InputStream inputStream = ResourceUtil.getValueMap(resourceToRead).get("allFundsDup", InputStream .class);

 

Thanks,

Ashwin Raju