
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Base64 cannot be resolved
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
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you try to import Base64 in the tJavaRow Advanced Settings?
import org.apache.commons.codec.binary.Base64;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
pics is data it's true!
Talend is a java generator so you can build your own component in java using tJava tJavaFlex tJavarRow.
tLibraryLoad allow to load external Jar.
but your code must be able to be integrated into Talends generated one.
you can use Base64 to encode your pics.
you may load java.util if you need it (be careful the last loaded lib is erasing previous one)
Good luck

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think that you have to also add your library on preferences/java/BuildPath/user Libraries.
je suis bien francophone, mais le forum a pour objectif d'etre réutilisable par tous.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you try to import Base64 in the tJavaRow Advanced Settings?
import org.apache.commons.codec.binary.Base64;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yannick

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@abelya, great!
However, you should mark the answer that help you, not your own.
