There might be a silly mistake am doing it. but am trying to load a jpeg photo to ldap via java and facing small issue.
Currently in mule-3 we use invoke java and store it in ldap and when we download from ldap we get actual image. this is how its getting stored
and here is high level java code
In Mule-4 there is no event context and java module itself got changed. so am using similar java program and trying to load to ldap. its getting loaded but when i download its not an image.
this is how its storing in ldap, some extra content in the beginning it seems. below is my java code
%dw 2.0
import java!imaging::UploadPhotoToAD
import * from dw::core::Binaries
import * from dw::core::Numbers
output application/java
---
UploadPhotoToAD::updateEntry(ldap.image as Binary, ldap.userDN, ldap.usersDN, ldap.url, ldap.authDN, ldap.authPassword)
Any idea what am missing here or anything needs to be changed
The problem is using String for binaries. You are having the same problem mentioned at https://stackoverflow.com/a/6544206/721855 because of using Strings for binaries. You should not use Strings at any point of reading or processing the image. Nor in the flow nor in Java.
Try in the flow use as Binary {class: "byte[]"}
to force the -already- binary to be a byte array and set the type of ba
also as a byte array (byte[]
).
I'm not sure what happens with the file read before it ends in ldap.image so ensure it is not transformed in any way, even implicitly in an expression. Remember that in Mule 4 expressions are DataWeave transformation.