I’ve tried to use UniversalDataWriter without success and have now switched to CustomJavaWriter. I would like to write a file as image from a database BLOB.
I’ve a loop to process each record and then this code:
Object objLogo = record.getField(“logo”).getValue();
String fileUrl = “…”;
try (OutputStream os = getOutputStream(fileUrl, false)) {
os.write(objLogo);
}
catch (IOException e) {
throw new JetelRuntimeException(e);
}
I don’t know if the Clover byte is directly mapped to a Java byte / byte array. I’ve checked the javadoc without success.
What is the best java object to map the defined Clover byte to? Could you help me?
Found the solution - it’s simple - byte field type has to be mapped to byte array as:
Object objLogo = record.getField(“logo”).getValue();
byte logo = (byte) objLogo;
try (OutputStream os = getOutputStream(fileUrl, false)) {
os.write(logo);
}
catch (IOException e) {
throw new JetelRuntimeException(e);
}
I am glad to see that you have successfully achieved your goal using the CustomJavaComponent. Thanks for posting the solution.
However, I am a little bit concerned about the UniversalDataWriter difficulties as well. Would you be so kind and tell me what exactly have you experienced? As a matter of fact, the UniversalDataWriter should be able to write the byte field type to file as well. I have created a simple graph for your review (in attachment, use any picture as input data). Please review especially the metadata setup: