Sling Model Binary Inject | Community
Skip to main content
April 4, 2023

Sling Model Binary Inject

  • April 4, 2023
  • 1 reply
  • 2135 views

Hi,

 

trying to adapt to resource class and i have a binary field with @586265. I try accessing the binary field and it says org.apache.sling.models.impl.injectors.ResourcePathInjector Could not retrieve resource at path {{the values stored at the variable }} for field {{property name}}. Since it is required it won't be injected.

 

So tried adapting to valuemapvalue,error is gone but the property is null  or does not exist

any inputs?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

arunpatidar
Community Advisor
Community Advisor
April 5, 2023

I would say adapt as resource or then read the binary property using InputStream.

Arun Patidar
April 5, 2023

I did the same but are you trying to say adapt the property as resource? Can you please elaborate and give some more details on how this can be done 

 

nodeA has property 

binaryprop binary value 

arunpatidar
Community Advisor
Community Advisor
April 6, 2023

Hi Arun

thanks,
Maybe I didn state the concern well.. my concern is more of adapting the node samplenode of my:unstructured type to a resource class via sling model and getting the binary property Into it 

 

 

what i observed is that other custom properties injected were retrieved but not the binary, I had taken the route of creating init method within sling model and obtaining the binary by reading the property from node path again via resolver.getresource(node path)  

that worked but if I do a get on the binary property that does not work 

 

 


Hi @nitrohazedev 
could you please share your code which you are you using to retrieve Binary property inside init method?

Arun Patidar