Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Image files into BLOB

Hello,
I have a list of jpg files I need to put in BLOB fields.
The name of the file corresponds to the ID of the datas to which the images owned. So I need to get the name of the jpg file, to compare it to the ID in the database and then to set the jpg file contains for the ID in the database.
I have written this job, but I have the following error (see attached files).
I think it's coming from the settings 'File Name' of the tFileInputDelimited_3.
Is the way of my job correct or am I totally wrong?
How can I do that?
Thanks
I use TOS 3.0.4
Labels (2)
12 Replies
Anonymous
Not applicable
Author

I think there should be a "iterate" link between the tFileList and the tFileInputDelimited_3.
Then, the tFileInputDelimited is not a good idea to put the content of an image file in a BLOB : the image file contains binary data whereas tFileInputDelimited is reading text data.
You'll probably have to create your own tFileInputBinary component.
Anonymous
Not applicable
Author

Hello,
regarding that post https://community.talend.com/t5/Design-and-Development/resolved-File-into-BLOB/td-p/67476, I'm not totally wrong. I agree that it will not works using the tFileInputDelimited_3.
But I don't know how to get in the same job (transaction) the name of the file to join it with the ID of PER_PERSONNE and the binary contain of the file. I must have twice in the input of the tMap_3.
If I put a "iterate" link between the tFileList and the tFileInputDelimited_3 I can't then put a link from the tMap_1 to tMap2 ou tMap_3.
I have the same problem If I put a link between the tFileProperties_2 and the tFileInputDelimited_3
Could somebody help me?
Thanks
Anonymous
Not applicable
Author

Hello mamouroux
From the error mesage, I see the error come from tFileInputDelimited_1, but I don't see this component in your job.
Best regards

shong
Anonymous
Not applicable
Author

Hello,
Sorry, I have found how to do, but now I have an other error:
Exception in component tOracleOutput_1
java.sql.SQLException: Type de colonne non valide
This error has been already explained in that topic,
https://community.talend.com/t5/Design-and-Development/Issue-on-CLOB-or-BLOB-datatype-while-insert-i...
but I doesn't know how to use setBlob instead of setObject.
I can't change anything in the code.
Please could you explian me how to do that?
Thanks
Anonymous
Not applicable
Author

Hello
But I don't know how to create one. And, is it possible to call it from the tMap ?

Go go Repository-->Code-->Routine and right click on 'Routine', then select 'create a new routine'.
For example, if you create a new routine call:
Forum6799 and there is a method in it: ByteArrayFromFile
  package routines;
public class Forum6799 {
public static Object ByteArrayFromFile(String filePath) {
try {
java.io.FileInputStream fis = new java.io.FileInputStream(filePath);
byte[] incoming_file_data = new byte;
fis.read(incoming_file_data);
fis.close();
return incoming_file_data;
} catch (Exception err) {
err.printStackTrace();
return null;
}
}
}

Assuming the job looks like:
tFileInputDelimited--row1--tMap--tMysqlOutput
On tMap, set the talend type as Object and db type as Blob, call the routine on expression:
Forum6799.ByteArrayFromFile(row1.filePath)
Let me know if you have any questions!!
Best regards
shong
Anonymous
Not applicable
Author

Hello, thx for the reply !
but now I have a java.lang.ClassCastException: [B cannot be cast to oracle.sql.BLOB
Anonymous
Not applicable
Author

Hello
Please upload some screenshots of your job, so I can see where do you make a mistake.
Best regards

shong
Anonymous
Not applicable
Author

Anonymous
Not applicable
Author

Here are screenshots of the job and inside the tMap

In the tMap I have hardcoded the path of the pdf to insert as a blob for test purpose.
Thx for your help