Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I need to download photos from oracle database and write them to jpg files in base64. Downloading and writing to jpg files works fine. Now i'm trying to use java.util.Base64.encodeBase64 but i have two problems.
Here is the code in tJavaRow component before trying to encode in base64 :
byte[] bytes = baos.toByteArray());
output_row.PHOTO = bytes;
output_row.PHOTO is object type
Now i add the encoding :
byte[] bytes = baos.toByteArray());
output_row.PHOTO = Base64.encodeBase64(bytes);
i have changed output_row.PHOTO to string type
When i try to run the job, the message is "Base64 cannot be resolved"
I i change to "output_row.PHOTO = java.util.Base64.encodeBase64(bytes);" the message is now "the method encodebase64(byte ) is undefined for the type base64"
First question : is Base64 really recognized by talend and why do i have to add java.util ?
Second question : am i wrong trying to use encodebase64 to convert my photo to base64 ?
Thank you for help
Yannick
Did you try to import Base64 in the tJavaRow Advanced Settings?
import org.apache.commons.codec.binary.Base64;
Bonjour François,
Vous devez être francophone ? Ce sera plus simple pour moi en français.
Je peux donc utiliser Base64 pour encoder mes images mais pourquoi cette class n'est elle pas reconnue ? J'utilise Talend Open Studio for Data Integration 6.0.0. Je pense que de base les packages commons-codec sont disponibles jusqu'en version 1.7. J'ai essayé d'ajouter le commons-code 1.11 mais rien n'y fait. Comment ajouter le fichier téléchargé pour que à la fin la classe Base64 soit reconnue dans mon composant tJavaRow ?
Cordialement
Did you try to import Base64 in the tJavaRow Advanced Settings?
import org.apache.commons.codec.binary.Base64;
You're perfectly right. The problem came from the place where i put the import command. It must be in the advanced settings and not in the basic settings.
Thank you very much.
@abelya, great!
However, you should mark the answer that help you, not your own.