CustomJavaWriter - How to write file from byte

Support/help with CloverETL (4.9) and CloverDX (5.0 or newer) implementation problems

tomapi
Posts: 3
Joined: Wed Jan 09, 2019 4:09 pm

CustomJavaWriter - How to write file from byte

Postby tomapi » Mon Jul 20, 2020 3:57 pm

Hello,

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?

Thanks,

Thomas

tomapi
Posts: 3
Joined: Wed Jan 09, 2019 4:09 pm

Re: CustomJavaWriter - How to write file from byte

Postby tomapi » Tue Jul 21, 2020 5:42 pm

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);
}

jandikovae
Posts: 46
Joined: Fri Nov 04, 2016 8:51 am

Re: CustomJavaWriter - How to write file from byte

Postby jandikovae » Wed Jul 29, 2020 9:35 am

Hi Thomas,

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:

metadataByte.jpg
metadataByte.jpg (112.41 KiB) Viewed 35 times


Please let me know what is your use case and what issue exactly you have encountered as I can provide more details. Thank you, Eva
Attachments
byteTest.grf
Example
(1.03 KiB) Downloaded 3 times
---
Eva Jandikova
CloverCARE Support
CloverDX

Visit us online at http://www.cloverdx.com


cron