Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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

Labels (4)
1 Solution

Accepted Solutions
TRF
Creator III
Creator III

Did you try to import Base64 in the tJavaRow Advanced Settings?

import org.apache.commons.codec.binary.Base64;

View solution in original post

7 Replies
fdenis
Creator III
Creator III

Talend is an ETL (extract Transform and Load data)
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
Anonymous
Not applicable
Author

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

fdenis
Creator III
Creator III

did you try to use tLoadLibrary?
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.
TRF
Creator III
Creator III

Did you try to import Base64 in the tJavaRow Advanced Settings?

import org.apache.commons.codec.binary.Base64;
Anonymous
Not applicable
Author

Thank you for your help. The problem in my tJavaRow is that i did put the import command in the basic setting with the main code instead of the advanced settings. Now Base64 class is resolved. It's a smal step for humanity but a big one for me. I 've tried tLibraryLoad but it was not necessary.
Yannick
Anonymous
Not applicable
Author

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.

TRF
Creator III
Creator III

@abelya, great!

However, you should mark the answer that help you, not your own.